Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Dilemma: Inheritance vs Cachin
icon8.gif  Dilemma: Inheritance vs Cachin [message #1694943] Sun, 10 May 2015 07:16 Go to next message
Rodrigue Lagoue is currently offline Rodrigue LagoueFriend
Messages: 2
Registered: July 2009
Junior Member
Hi folks,

i'm now using eclipselink (JPA) for more than 7 years, and just facing for the first time a situation where I will have to configure some caching. So let's come to my dilemma.

During the years I have evolved to a class that factorize the common fields every entities needs to an abstract class named BaseEntity. This is the case for the fields: id, version for example. This class also implements many useful methods like #equals or #hashCode() etc..

Since I'm have to add some configure some special caching to improve the performance of my application, I'm really blocked by the current phrase I found in the eclipselink configuration everywhere: "If you define the @Cache annotation on an inheritance subclass, the annotation will be ignored." Embarrassed

This means for me (and hopefully for many people out there) that I will have to choose between the reuse of a huge code base and the setting of the caching. And this is not good at all.

Maybe someone already faced this dilemma, and I would like to know how he/she/they solved it.

Thank you
Rodrigue
Re: Dilemma: Inheritance vs Cachin [message #1695531 is a reply to message #1694943] Fri, 15 May 2015 18:58 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
This statement refers to JPA inheritance, not java inheritance - it does not apply if your baseEntity is a mapped superclass or other non-entity class in the hierarchy. With JPA inheritance, generally the subclasses are also considered instances of the root class, and so all will share the root entity's cache. Basically, any class type that would get returned from "Select r from Root r" should be put in the same cache (table per class inheritance not withstanding).

Re: Dilemma: Inheritance vs Cachin [message #1695988 is a reply to message #1695531] Wed, 20 May 2015 22:56 Go to previous messageGo to next message
Rodrigue Lagoue is currently offline Rodrigue LagoueFriend
Messages: 2
Registered: July 2009
Junior Member
Hi Chris,

thank you for your reaction. Let's assume the following situation:

@MappedSuperclass
public abstract class A
{
 // some common properties like id
}
@Entity
public abstract class B extends A
{
// adds to A some more properties like timestamp for eg.
}
@Entity
public class C extends A
{
 // properties specific for entity C
}


My understanding of the restriction is that it would be only possible to configure caching on the class A. Any caching configuration on the classes B and C will be ignored. Am I right?

Thank you a lot again
Re: Dilemma: Inheritance vs Cachin [message #1696321 is a reply to message #1695988] Mon, 25 May 2015 15:22 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
I would assume the opposite (that cache info in B/C would override settings put in A), as A is not an entity and so does not have its own cache, but the best way to be sure is to test it.

[Updated on: Mon, 25 May 2015 15:22]

Report message to a moderator

Previous Topic:Problem with join fetching multiple entities
Next Topic:Issue with EclipseLink and union when using hsqldb
Goto Forum:
  


Current Time: Fri Mar 29 08:32:35 GMT 2024

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

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

Back to the top