I'm trying to change one of my model classes from a "class" type of object to a "union-subclass".
I have two classes that map to two tables. Article Maps to Article and ObjectInfo maps to ObjectInfo. Article extends ObjectInfo (ObjectInfo is not abstract) and is referenced as a set in the Article class. Table Article has all the columns defined in ObjectInfo plus a few more. Everything works fine when not using a union-subclass, but my XML is a little redundant and I want to use a union-subclass.
When I change my XML to be a union-subclass, I get an exception: org.hibernate.MappingException: Unknown entity: Article.
Sample classes:
Code:
class Article extends ObjectInfo
{
public int state;
public Set<ObjectInfo> parts;
}
class ObjectInfo
{
public String primaryID;
public String otherProperty;
}
This XML config works fine:
Code:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.joe.blah">
<class name="Article" table="Article">
<id name="id" type="org.ambraproject.hibernate.URIType" column="uri"/>
<property name="state" type="int" column="state"/>
<list name="parts" table="ArticlePartsJoinTable" cascade="all">
<key column="articleUri"/>
<list-index column="sortOrder"/>
<many-to-many class="ObjectInfo" column="objectInfoUri"/>
</list>
</class>
</hibernate-mapping>
This XML config fails:
Code:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.joe.blah">
<union-subclass name="Article" entity-name="Article"
table="Article" extends="ObjectInfo">
<property name="state" type="int" column="state"/>
<list name="parts" table="ArticlePartsJoinTable" cascade="all">
<key column="articleUri"/>
<list-index column="sortOrder"/>
<many-to-many class="ObjectInfo" column="objectInfoUri"/>
</list>
</union-subclass>
</hibernate-mapping>
It is probably worth noting that I'm pulling objects from another ORM that sometimes passes in strange class names. If I remove the entity-name property I get this exception:
Code:
Unable to resolve entity name from Class [org.joe.blah.Article_$$_javassist_4] expected instance/subclass of [org.joe.blah.ObjectInfo]
Thanks in advance, hopefully, I'm just missing something simple.