Hello, I've the following setup: 0) EAR file with the following inside 1) 2 EJB jar files (jar1.jar and jar2.jar) with their own persistence.xmls and entitymanagers (em1 and em2) 2) Entitymanagers are using different datasources (but to the same db)
in jar1.jar i've | @Entity | @Table(name = "CalEvent", catalog = "lportal", uniqueConstraints = {}) | @Inheritance(strategy = InheritanceType.JOINED) | public class Calevent implements java.io.Serializable { and in jar2.jar i've @Entity | @Name("task") | @Table(name = "task", catalog = "tc", uniqueConstraints = {}) | @Inheritance(strategy = InheritanceType.JOINED) | public class Task extends Calevent { | also in jar2.jar i've a SFSB which is acting as on action where new Task's are created: | Task t = new Task(); | t.setBlaBla(); | em2.persist(t); | Now, however, during the insertion it doesn't work. I've figured that it's because the super classes instance is not persisted/commited to the db and thus i'm using two different ems / datasources the em2/ jdbc connection2 can't yet see the super classes stuff in the db. So, i tried to set up | <property name="hibernate.transaction.flush_before_completion" value="true" /> in persistence.xml, to see if it helps, but the setting is ignored by HEM. >From log i can see that the calevent's insert SQL is before task's, but em1 >(calevent's) is not yet synced to the db so the row doesn't actually exists in >the db yet. And there seems to be foreing key constraint (generated by >Hibernate) between task.eventId and calevent.eventId which is causing the very >distracting duplicate key error message. anonymous wrote : | 4093449 15:25:47,379 INFO [STDOUT] Hibernate: insert into lportal.CalEvent (type_, startDate, description, userName, userId, companyId, groupId, modifiedDate, createDate, title, firstReminder, secondReminder, remindBy, recurrence, endDate, durationHour, durationMinute, allDay, timeZoneSensitive, repeating, eventId) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) | 4093450 15:25:47,380 INFO [STDOUT] Hibernate: insert into tc.task(poikkeuksin, tehty, kohde_organizationId, eventId) values (?, ?, ?, ?) | 4095969 15:25:49,899 WARN [JDBCExceptionReporter] SQL Error: 1062, SQLState: 23000 | 4095970 15:25:49,900 ERROR [JDBCExceptionReporter] Duplicate entry '18' for key 1 | So, is there a way to force flush/commit on the insertion of calEvent? The reason that i've two EntityManagers and two different datasources (with differens users and privileges inside the db) is that i want to use ejb3/hibs create/update schema but also to make sure that em2 doesn't mess with the db schema presented by em1. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3974535#3974535 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3974535 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user