Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] find always does db lookup?

By default, when you do an em.find(), in the same em, you will get the same entity without a DB lookup. This is likely the same in all persistence providers.

In other circumstances, you may or may not get the same object.

i.e. In a different em, there is a reasonable chance, a find will return the same object without a db lookup. (dependant on cache settings and number of reads running in app)

When running a JPA query, you will see SQL, but if the object is in the cache, it will be returned and not changed based on the data in the DB.

JPA provides a refresh() API to allow refreshing and EclipseLink provides a refresh query hint as well along with a number of cache settings that can be used to alter this behavior.

-Tom

jehanzeb.qayyum@xxxxxxxxx wrote:
Hi,

If I find an entity, eclipselink gets it from db. I do some changes on the entity.  Now what will happen if I again find the same entity (same PK)? Will it do another db lookup to get db copy or return the changed entity from em context.
Thanks

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


Back to the top