| [eclipselink-users] Order of persist operations |
| Hi guys, I am experiencing a weird imho behaviour of Eclipselink and I'd really like to hear some other opinions . I have a pretty simple entity with assigned IDs; @Entity @Table(name="ROLE") public class Role implements Serializable { private static final long serialVersionUID = 1L; @Id @Column(name="ID", length=20, nullable=false) public String id; } I am executing the following operations: public static void main(String[] args) { EntityManagerFactory emf = Persistence.createEntityManagerFactory("EclipseLinkJPATest"); EntityManager em = emf.createEntityManager(); em.getTransaction().begin(); for (int i = 0; i < 10; i++) { Role r = new Role(); r.id = "TEST" + i; em.persist(r); } em.getTransaction().commit(); em.close(); emf.close(); } And I'd expect that the INSERT queries will be executed in the same order as the persist() method is called: TEST0, TEST1, TEST2 , etc. But in the real life the insert queries are in a random order every time: EL Fine]: sql: 2013-01-17 12:13:58.11--ClientSession(1694665796)--Connection(1795160456)--INSERT INTO ROLE (ID) VALUES (?) bind => [TEST1] [EL Fine]: sql: 2013-01-17 12:13:58.113--ClientSession(1694665796)--Connection(1795160456)--INSERT INTO ROLE (ID) VALUES (?) bind => [TEST6] [EL Fine]: sql: 2013-01-17 12:13:58.114--ClientSession(1694665796)--Connection(1795160456)--INSERT INTO ROLE (ID) VALUES (?) bind => [TEST2] [EL Fine]: sql: 2013-01-17 12:13:58.115--ClientSession(1694665796)--Connection(1795160456)--INSERT INTO ROLE (ID) VALUES (?) bind => [TEST7] [EL Fine]: sql: 2013-01-17 12:13:58.117--ClientSession(1694665796)--Connection(1795160456)--INSERT INTO ROLE (ID) VALUES (?) bind => [TEST4] [EL Fine]: sql: 2013-01-17 12:13:58.121--ClientSession(1694665796)--Connection(1795160456)--INSERT INTO ROLE (ID) VALUES (?) bind => [TEST8] [EL Fine]: sql: 2013-01-17 12:13:58.123--ClientSession(1694665796)--Connection(1795160456)--INSERT INTO ROLE (ID) VALUES (?) bind => [TEST3] [EL Fine]: sql: 2013-01-17 12:13:58.124--ClientSession(1694665796)--Connection(1795160456)--INSERT INTO ROLE (ID) VALUES (?) bind => [TEST9] [EL Fine]: sql: 2013-01-17 12:13:58.126--ClientSession(1694665796)--Connection(1795160456)--INSERT INTO ROLE (ID) VALUES (?) bind => [TEST5] [EL Fine]: sql: 2013-01-17 12:13:58.127--ClientSession(1694665796)--Connection(1795160456)--INSERT INTO ROLE (ID) VALUES (?) bind => [TEST0] As you can see the order if insert queries is: TEST1, TEST6, TEST2, TEST7, TEST4, etc. That is really weird and wrong ! :) I dug a lot and could not find a solution. Please help :) Thanks in advance, Deyan |