Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] If JPA Cache is enabled it's possible to get more Entitys as stored in the underlying database

JPA will do some work to figure out which objects it needs to insert. One of the things it will do is optimize the inserts by not running two insert statements on the same object. It will do a number of checks to tell if two objects are the same. It will check for objects with the same identity (i.e. two objects that are "==") It will also check for two objects with the same @Id.

In your case when you insert the same object twice, the identity check is bypassing the extra insert.

On 15/03/2013 10:03 AM, helmut.at.work wrote:
Thanks the "REFRESH" point me in the right direction.

There is one thing left I don't understand. My Example isn't a real world
example, but I try to understand the JPA mechanism.
In my example there are 3  ChildNodes in the Collection. 2 of them point to
the same object.
The ChildNode entity use:
...
     @Id
     @GeneratedValue
     private long id;
...
and the ChildNode.equals  uses "id" to compare objects.

Shouldn't JPA insert than 3 instead of 2 ChildNodes into DB? Seems to me
more logical.



--
View this message in context: http://eclipse.1072660.n5.nabble.com/If-JPA-Cache-is-enabled-it-s-possible-to-get-more-Entitys-as-stored-in-the-underlying-database-tp158489p158548.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top