users@glassfish.java.net

Re: TopLink: Order of entities in collection?

From: <glassfish_at_javadesktop.org>
Date: Wed, 11 Apr 2007 13:27:12 PDT

It is not clear to me what you are expecting. Are you expecting the INSERT statements to print in a certain order ? Or are youo expecting the database table to contain some kind of inherent ordering? Could you explain a bit more what you are expecting and how you use that ordering - maybe with that information, I can help you find a solution for your problem.

TopLink Essentials (and likely most other JPA implementations) will not necessarily order inserts in the order you call persist. In general, we build a dependancy graph based on the objects that are persistent and use that graph to do our insertions.

If you want statements to be called in a specific order, your best strategy is to flush the entity manager each time you want to ensure a statement is written.
[Message sent by forum member 'tware' (tware)]

http://forums.java.net/jive/thread.jspa?messageID=211946