Hibernate version:
2.1.6
Name and version of the database you are using:
Oracle 10g
Hi,
I have the following hierarchy I'm trying to represent in hibernate.
TypeA implements IType
TypeB implements IType
TypeC implements IType
IType has a Map of Entities, so the entities table has a getIType method
which uses <any> mapping and the entities table has type and itype_key
columns.
TypeA, TypeB and TypeC declare the Map with a <one-to-many> mapping to
the class Entity.
Things work great when I want to save the information to the database,
I can do the following:
TypeA a = new TypeA();
a.setEntities(mapOfEntitiesForA);
TypeB b = new TypeB();
b.setEntities(mapOfEntitiesForB);
TypeC c = new TypeC();
c.setEntities(mapOfEntitiesForC);
session.save(a);
session.save(b);
session.save(c);
And in the entities table, the type column will be filled with the
class type of A, B or C as appropriate.
But when I read in the data, such as the following:
TypeA a1 = session.get(TypeA.class, a.getKey())
a1.getEntities() contains all the entities, not just the ones
where the type field is TypeA. The SQL select statement issued
by hibernate doesn't search by type, just by TypeA.key
Any ideas where I'm going wrong?
Mark
|