Sure, you can use another persistence unit. When you create session you need to build up environment that contains entity manager factory, and that is the place where you should use your new name.
Alternative, could be to get rid of second instance of persistence unit and reuse that one loaded by console.
thanks for your reply. You mean I should add the persistence unit name as property ? I can see the KnowledgeBase can be started with a Property file:
Properties properties = new Properties();
properties.setProperty( "org.drools.sequential", "true");
KnowledgeBaseConfiguration kbConf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(properties, myClassLoader);
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbConf);
If so which is the right key to set for the persistence unit name ?
Thanks a lot
Maybe I found it:
EntityManagerFactory emfTask = Persistence.createEntityManagerFactory( "org.jbpm.task" );
is that one the right place to declare the persistence unit ?
Yes, this is the way you build up entity manager factory but you found for task server and what you are looking for (as original post refers to) is session state persistence.
So you should look for a place in your application where you create stateful sessions rather than knowledge base. There you should utilize JPAKnowledgeService to create session where one of the arguments for the newStatefulKnowledgeSession method is environment that should contain entity manager factory instance.