Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
13.4. Persistence configuration
13.4.1. Persistence configuration Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Although persistence is not used by default, the dependencies needed are available in the runtime directory as jar files
.
Persistence is defined per session and you can define it either using the
JBPMHelper
class after you create a session or using the JPAKnowledgeService
to create your session. The latter option provides more flexibility, while JBPMHelper
has a method to create a session, and uses a configuration file to configure this session.
13.4.2. Configuring persistence using JBPMHelper Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
To configure persistence of your session using JBPMHelper, do the following:
- Define your application to use an appropriate JBPMHelper session construtor:
KieSession ksession = JBPMHelper.newKieSession(kbase);
KieSession ksession = JBPMHelper.loadKieSession(kbase, sessionId);
- Configure the persistence in the
jBPM.properties
file.Example 13.1. A sample jBPM.properties file with persistence for the in-memory H2 database
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Any invocations on the session will now trigger the persistance process.
Make sure the datasource is up and running on engine start. If you are running the in-memory H2 database, you can start the database from your application using the
JBPMHelper.startH2Server();
method call and register it with the engine using JBPMHelper.setupDataSource();
method call.
13.4.3. Configuring persistence using JPAKnowledgeService Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
To create your knowledge session and configure its persistence using JPAKnowledgeService, do the following:
- Define your application to use the knowledge session created by JPAKnowledgeService:
- Define the session based on a knowledge base, a knowledge session configuration, and an environment. The environment must contain a reference to your Entity Manager Factory:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Define the session based on a specific session id.
// recreate the session from database using the sessionId ksession = JPAKnowledgeService.loadKieSession(sessionId, kbase, null, env );
// recreate the session from database using the sessionId ksession = JPAKnowledgeService.loadKieSession(sessionId, kbase, null, env );
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- Configure the persistence in the
META-INF/persistence.xml
file: configure JPA to use Hibernate and the respective database.Information on how to configure data source on your application server should be available in the documentation delivered with the application server. For this information for JBoss Enterprise Application Platform, see the Administration and Configuration Guide for this product.Example 13.2. A sample persistence.xml file with persistence for an H2 data source
jdbc/jbpm-ds
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Any invocations on the session will now trigger the persistance process.
Make sure the datasource is up and running on engine start. If you are running the in-memory H2 database, you can start the database from your application using the
JBPMHelper.startH2Server();
method call and register it with the engine using JBPMHelper.setupDataSource();
method call.
Note
If you are running JBoss BPM Suite in a simple Java environment, your data source configuration will be similar to the following: