These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: union-subclass exception
PostPosted: Tue Mar 15, 2011 9:04 pm 
Newbie

Joined: Tue Mar 15, 2011 8:43 pm
Posts: 2
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.