[hibernate-dev] Natural ids and inheritance
Demetz, Guenther
Guenther.Demetz at wuerth-phoenix.com
Thu Mar 1 04:05:02 EST 2012
John Verhaeg wrote: I probably don't understand the complexities with this, but wouldn't the ID values in AA have to be completely independent of the values in A?
Yes, that's exactly what I'd expected originally and that's it what would be a nice to have !
In our model for example we have following entity classes:
class Article {
@Id
Id generated key;
@NaturalId
String articlenumber;
}
class Carton extends Article {
@NaturalId
int cartonId;
}
so it would be nice to can lookup a Carton as well as through its articleNumber
session.bySimpleNaturalId(Article.class).load("04712342");
as well as through it's carton number
session.bySimpleNaturalId(Carton.class).load(10);
As said, this would be a nice to have (maybe in a future release),
but I can also live without.
@Steve: As you rejected issue "HHH-7113 NaturalIdLoadAccess not properly working on mutable NaturalId's"
you force me to re-open the issue again because HHH-7113 actually intended to address following 2 bugs:
1. After updating the value of a mutable NaturalId, the entity object can be retrieved with the new value, but also with the old value.
On deletions the internal NaturalId cache is synchronized properly but not on modifications.
2. When inserting or deleting an entity object, the entity-persister of the object's concrete class is considered as cache-region.
When loading an entity object by NaturalId , indeed the entity-persister of the declaring class is considered as cache-region ( Session.byNaturalId(declaringclass))).
As declaringclass may be a superclass of the concrete class, the NaturalId-synchronisation may try to synchronize the wrong cache-region.
THIS 2 BUGS ARE ALSO HAPPENING WITH NATURALID'S DECLARED EXCLUSIVELY IN ROOT CLASS!
I will open regarding issue with testcase asap.
best regards
G.Demetz
More information about the hibernate-dev
mailing list