[hibernate-dev] Natural ids and inheritance

Demetz, Guenther Guenther.Demetz at wuerth-phoenix.com
Thu Mar 1 12:11:47 EST 2012


Hi Steve,

>> Caching should be using the root persister of the hierarchy for cache keys.

Hm,  it probably depends on how you fixed HHH-7129.

Is following hierarchy allowed after HHH-7129 ?

@Entity
class A {
  @Id
  int id;
}

@Entity
class Subclass1 extends A  {
  @NaturalId
  String name;
}

@Entity
class  Subclass2 extends A  {
  @NaturalId
  String card;
}

If it is still allowed, then caching 

session.bySimpleNaturalId(SubClass2.class).load("g");

should't use the root persisterA, it should use persisterSubclass2, otherwise 

session.bySimpleNaturalId(SubClass1.class).load("g");

would overwrite the previous cached entry, right?




More information about the hibernate-dev mailing list