此内容没有您所选择的语言版本。
16.2. Defining transactions
To define a transaction, do the following:
Register the transaction manager in your environment:
Example 16.1. Code with transaction manager registration
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Initialize the KieSession:
// get the KieSession RuntimeManager manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment); RuntimeEngine runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get()); KieSession ksession = runtime.getKieSession();
// get the KieSession RuntimeManager manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment); RuntimeEngine runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get()); KieSession ksession = runtime.getKieSession();
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the transaction manager in
jndi.properties
:Example 16.2. Definition of Bitronix transaction manager in jndi.properties
java.naming.factory.initial=bitronix.tm.jndi.BitronixInitialContextFactory
java.naming.factory.initial=bitronix.tm.jndi.BitronixInitialContextFactory
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Using another transaction managerTo use a different JTA transaction manager, edit the
hibernate.transaction.manager_lookup_class
, the transaction manager property, in thepersistence.xml
file to load your transaction manager.For example, if choosing JBoss Transaction Manager:
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the start and the end of the transaction.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow