このコンテンツは選択した言語では利用できません。
14.2. Defining transactions
To define a transaction, do the following:
- Register the transaction manager in your environment.
Example 14.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 14.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 Note
To 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.Example 14.3. JBoss Transaction Manager set as 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