Problem: Our Class-Hierarchy is somewhat complex.
We have a class Ad, AdBig and AdSmall, Article and an Interface calles PageElement. Ad ist the superclass of both AdBig and Small. Article and AdBig also impelement the Interface PageElement.
In yet another Class, we would like to have a Set of PageElements, which of course may contain both Articles as well as AdBigs...
Following the official Docs we would have to use Table-Per-Concrete-Class with implicit Inheritence, but a mapping Exception gets thrown.
Code:
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.Set, for columns: [org.hibernate.mapping.Column(inhalt)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.Property.isValid(Property.java:185)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:440)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1102)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
at de.nordakademie.schnak.util.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 1 more
Mapping:Code:
<class name="Ad"> ... simply mapping some properties ...</class>
Code:
<subclass name="AdBig/Small" extends="Ad">...</subclass>
Code:
<class name="Category">
...
<set name="content">
<key column="id"/>
<one-to-many class="PageElement" />
</set>
</class>
We also have other Classes who may hold instances to those Ads and Articles.. is there a way to implement this in Hibernate with hbm.xml-Files?
Thanks in advance
XriS