Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Force eclipselink to avoid pulling the same object on separate queries on the same entity(How to globally force eclipselink to avoid pulling the same object on separate queries on the same entity?)
Force eclipselink to avoid pulling the same object on separate queries on the same entity [message #1800942] Thu, 10 January 2019 06:44
Boris Okolodkov is currently offline Boris OkolodkovFriend
Messages: 1
Registered: January 2019
Junior Member
Hello everyone.

Maybe my question is dumb and I don't know what I'm talking about, but still. Is there any way to globally force eclipselink (persistence unit or entity manager configuration) to avoid fetched entities of the same type being pulled from L1 cache (if this is the case)?

Example: Let's say Ive got an entity annotated with @Cacheable(false) while having no additional entity manager properties except weaving turned off. So if I execute a findById() on the same id twice, the actual object in memory returned by these 2 calls is the same for me.

Moreover, this becomes a real brain-hurting problem when you have 2 tables connected by a foreign key (e.g. Employee -> Department). And first you fetch the parent object "Employee" containing it's child "Department" (by introspection). And later you fetch the same child object "Department" separately for some another purpose (like filling a select field to offer a possible change of the related parent property, i.e. move employee to another department). The problem here would be that the "Employee" will point to the very same object in memory "Department" as the separately fetched object (one of the objects in my select list). So basically I need to be aware all the time that when I change something inside my parent's child (through parent) I actually modify one of my select combo field objects.

The strange thing is that I do not get this behavior when running for ex. in WildFly (with integrated eclipselink 2.7) but when it's Spring Boot or some simple external container (same eclipselink version) it happens every time.

Also, anticipating some comments, I know that I'm fighting the very reason the cache was invented and my problem is more related to bad practices, but, in my particular case, it's an old and badly written system that I need to migrate to Spring Boot and I don't know what to do, except to rewrite it completely.

Any ideas?

P.S. I can provide some code if my narrative does not explain the problem in full.

[Updated on: Thu, 10 January 2019 21:19]

Report message to a moderator

Previous Topic:Migrate RCP to Java11 using MOXy
Next Topic:what really means weave and why is important
Goto Forum:
  


Current Time: Tue Apr 23 08:23:25 GMT 2024

Powered by FUDForum. Page generated in 0.03952 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top