我正在尝试制作一个基于spring mvc和hibernate的drools应用程序。
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");
createEntityManagerFactory
做了什么?
它是否会从数据库中删除所有表并每次都创建一个新表?
因为在我的任务表中,每次只包含一行?
为什么?
提前致谢。
答案 0 :(得分:0)
项目中有persistence.xml
个文件,其中包含行
<persistence-unit name="org.drools.task">
你的桌子被打破了因为你有persistence.xml
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
create-drop
表示:在会话结束时删除架构
将值更改为validate
或update