[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Order of persist operations

Yannick, 

the output I have provided is from EclipseLink log and it is a result of the execution of the code that I have provided. 
In that code I am not reading or loading any entities, the only operation that I perform is persist(). 

I would like the the INSERT statements to be executed in the same sequence ( or order ) as the persist() calls. 

Regards, 
Deyan 
 
On Jan 17, 2013, at 14:59 , Yannick Majoros <yannick.majoros@xxxxxxxxx> wrote:

Deyan,

Why would you want to do that? Your scenario is wrong, jpa specs don't provide this possibility.

Btw, databases don't guarantee that they will return results in the same order even if they do in practise.

Just add an order column to your entity.
Best regards,

Yannick

Le 17 janv. 2013 13:46, "Deyan Tsvetanov" <deyan@xxxxxxxxxxxx> a écrit :
Marcin,

if I put flush() after each persist() it will work of course but will take too much time for lot of records.
What I need to do is to persist many records in the specified order in one transaction.
So far eclipselink fails to support that scenario  :(

Regards,
Deyan


On Jan 17, 2013, at 14:43 , Marcin Kwapisz <mkwapisz@xxxxxxxxxxxxx> wrote:

W dniu 2013-01-17 12:27, Deyan Tsvetanov pisze:
> Well, the order that EclipseLink chooses is RANDOM :)
> It is a fairly simple example, only 1 entity with only 1 column.
> I'd really expect that the INSERT statements are executed in same order as the persist() calls.
>
> My real-life use case is importing data from an XML file into the database.
> There are relations and FKs in my database and when exported and re-imported the order of the XML entries, persist() calls and INSERT statements is critical.
> EclipseLink basically inserts each XML entry randomly. Currently the only workaround is to flush after each persist call. It could work for few hundred calls,
> but not for few thousand.
>
> JPA says nothing about the order of the database operations. When writing the spec they probably have assumed that it would be logical to execute the database operations in the
> same order as the persist() or merge() calls.
> This is not the case of mixed remove(), persist() and merge() calls, in our case we have only persist() calls and the case is very simple.
>
> Best regards,
> Deyan
>
>
em.persist() places INSERT query in the cache.
em.getTransaction().commit() flushes the cache and the order of INSERTs is the same as in the cache (I think, I do not know how eclipselink is implemented).
Try to place em.flush after persist

Regards
Marcin
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users