Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2.2GA
Hey, I have a question regarding inheritance.
I have the following setup:
Code:
@Entity
@Table(name = "OBJECT")
public class DataObject {
..
@OneToMany(cascade = { CascadeType.ALL })
@MapKey(name="alias")
private Map<String, Property> properties;
..
}
@Entity
@Inheritance (strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="PTYPE",discriminatorType=DiscriminatorType.STRING)
@DiscriminatorValue("BaseProperty")
public abstract class Property implements Comparable {
..
}
@Entity
@DiscriminatorValue(value="TEXT")
public class TextProperty extends Property {
..
}
@Entity
@DiscriminatorValue(value="VARCHAR")
public class VarcharProperty extends Property {
..
}
When I create a DataObject and add two properties to it (one TextProperty and one VarcharProperty) and save the object
I get two entries in my Property table, one for each property with its own discriminator, and it looks fine.
But when I load the object again and try to iterate the properties, Hibernate generates some sql which my oracle database complains about.
Code:
select properties0_.OBJECT_id as OBJECT1_3_, properties0_.properties_id as properties2_3_,
(select a2.alias from Property as a2 where a2.id=properties0_.properties_id) as formula0_3_, property1_.id as id4_0_,
property1_.propertytype_id as property7_4_0_, property1_.name as name4_0_, property1_.sortorder as sortorder4_0_,
property1_.alias as alias4_0_, property1_.value as value4_0_, property1_.PTYPE as PTYPE4_0_, propertyty2_.id as id3_1_,
propertyty2_.alias as alias3_1_, propertyty2_.pclass_id as pclass3_3_1_, propertycl3_.id as id2_2_,
propertycl3_.name as name2_2_, propertycl3_.adminpage as adminpage2_2_, propertycl3_.javaclass as javaclass2_2_
from OBJECT_Property properties0_
left outer join Property property1_ on properties0_.properties_id=property1_.id
left outer join PROPERTYTYPE propertyty2_ on property1_.propertytype_id=propertyty2_.id
left outer join PROPERTYCLASS propertycl3_ on propertyty2_.pclass_id=propertycl3_.id
where properties0_.OBJECT_id=141
It complains about a missing right paranthesis in line 2, so I'm guessing my setup regarding the inheritance of the properties
is wrong for some reason, but I cant quite figure out what I've done wrong. Any ideas ?