jpa - How to start Transaction in JTA EntityManager -
i have jpa mapping hsqldb , persistence.xml reads below :
<persistence-unit name="hmc"> <jta-data-source>java:hmc</jta-data-source> <class>org.hmc.jpa.models.bloodgroup</class> <class>org.hmc.jpa.models.contactinfo</class> <properties> <property name=hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.jbosstransactionmanagerlookup"/> <property name="hibernate.dialect" value="org.hibernate.dialect.hsqldialect" /> </properties> </persistence-unit>
and entitymanager : entmanagerfactory = persistence.createentitymanagerfactory("hmc");
i have datasource defined in jboss5.1 hsqldb. if begin transaction, throws illegalstateexception : jta entitymanager cannot use gettransaction()
can let me know how start , commit transactions under these circumstances.
regards,
satya
this javadocs gettransaction says...
entitytransaction gettransaction()
return resource-level entitytransaction object. entitytransaction instance may used serially begin , commit multiple transactions. returns: entitytransaction instance throws: illegalstateexception - if invoked on jta entity manager
so means if transaction-type attribute jta jdbc xa datasource, you'd illegalstateexception.
suggested fix: try set transaction-type resource-local localtx jdbc datasource or else lead illegalstateexception.
Comments
Post a Comment