-
1. Re: flush database
kukeltje Jul 30, 2008 9:12 AM (in response to gnagy)Greg,
How's life? Unfortunately no Budapest for me this year. Parents went to Hungary, but I'm starting up my own business so no holiday (I think)
You can write a simple query that only retrieves the id's of finished processinstances (not running ones as you describe) and use those id's to delete the instances. You can even do something with the end date, so only ended processes with an end date of more than one month ago.
hth. -
2. Re: flush database
gnagy Jul 30, 2008 12:02 PM (in response to gnagy)Hi Ronald,
Well, I hope you'll find time to visit us anyway. Then again, there is always next year!
We found a solution to the problem. It's brute, but works. Basically, before, we dropped the whole jbpm database, and then restarted jboss as, thereby recreating all tables again. Then, I noticed which tables were empty after a fresh start, and now we just empty those tables when needed. Here is the code:
for(String table: new String[] {"jbpm_db.jbpm_bytearray", "jbpm_db.jbpm_byteblock", "jbpm_db.jbpm_comment", "jbpm_db.jbpm_decisionconditions", "jbpm_db.jbpm_exceptionhandler", "jbpm_db.jbpm_job", "jbpm_db.jbpm_log", "jbpm_db.jbpm_moduleinstance", "jbpm_db.jbpm_pooledactor", "jbpm_db.jbpm_processinstance", "jbpm_db.jbpm_runtimeaction", "jbpm_db.jbpm_swimlaneinstance", "jbpm_db.jbpm_taskactorpool", "jbpm_db.jbpm_taskcontroller", "jbpm_db.jbpm_taskinstance", "jbpm_db.jbpm_token", "jbpm_db.jbpm_tokenvariablemap", "jbpm_db.jbpm_variableaccess", "jbpm_db.jbpm_variableinstance"}) {
DbUtils.emptyTable(em, table);
}
and in DBUtils.java:
public static void emptyTable(EntityManager em, String tableName) {
Query query = em.createNativeQuery("delete from " + tableName);
query.executeUpdate();
}
Luckily we didn't run into foreign key integrity issues.
We really need to remove all process data from the jbpm database, since we also empty our domain database, and any references to our domain model in jbpm will not be valid anymore.
Thanks for the suggestion, and good luck with your startup! I hope it will be fun :)
Greg