简体   繁体   中英

Why multiple task is not coming in my drools application?

I am trying to make a drools application which is based on spring mvc and hibernate.

EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.drools.task");   
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
TaskService taskService = new TaskService(emf, systemEventListener);

TaskServiceSession taskSession = taskService.createSession();
taskSession.addUser(new User("Administrator"));
taskSession.addUser(new User("Myuser"));// can be set to logged in user at runtime

MinaTaskServer server = new MinaTaskServer(taskService);
Thread thread = new Thread(server);
thread.start();

ksession.getWorkItemManager().registerWorkItemHandler("Log",humanTaskHandler);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", wsHumanTaskHandler);

 KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
// start a new process instance
ksession.startProcess("HumanTaskSample");

What does createEntityManagerFactory does? Does it drop all my tables from the db and create a new one every time?

Because in my task table , everytime it contains only one rows?

Why??

Thanks in advance.

You have persistence.xml file in your project, that contains line

<persistence-unit name="org.drools.task">   

your table are drpped becouse you have next proprty in you persistence.xml

<property name="hibernate.hbm2ddl.auto" value="create-drop"/>    

create-drop means: drop the schema at the end of the session

Change value to validate or update

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM