-->
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.  [ 6 posts ] 
Author Message
 Post subject: Using joined-subclass and suclass
PostPosted: Thu Aug 25, 2005 8:44 am 
Newbie

Joined: Fri Aug 05, 2005 7:26 am
Posts: 17
Location: Santa Barbara d´Oeste SP Brasil
Hello guys.

I need to map my class using these strategies, joined-subclass and sucblass, so, I did this:

Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
    <class
        name="com.mypackage.MySuperClass"
        table="my_superclass_table"
    >

        <id
            name="id"
            column="id"
            type="java.lang.Integer"
        >
            <generator class="increment"/>
        </id>

        <discriminator
            column="type_class_name"
        />

        <property
            name="defaultValue"
            type="java.lang.String"
            update="true"
            insert="true"
            column="default_value"
        />
       
        <subclass
          name="com.mypackage.MySubClass"/>         
         
      <joined-subclass
         name="com.mypackage.MyJoinedSubClass"
         table="my_joinedsubclass_table"
      >
         <key
         />
            <property
               name="color"
               type="java.lang.String"
               update="true"
               insert="true"
               column="color"
            />
      </joined-subclass>
    </class>   
</hibernate-mapping>


But when I try to star my application, I receive this error message:
Code:
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array|query-list)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*)".


Can´t I have subclass mapping with joined-subclass?

Thanks
Sigrist


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 10:19 am 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
Nope. From the docs:

Quote:
Hibernate does not support mixing <subclass>, and <joined-subclass> and <union-subclass> mappings under the same root <class> element.
[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 10:33 am 
Newbie

Joined: Fri Apr 08, 2005 6:28 pm
Posts: 17
Location: US
Sigrist,

sorry, but subclass and joint-subclass are incompatible.

subclass assumes a table per class hierarchy (look at Hibernate Reference, 3.0.5 #10.1.1), i.e. one table contains all attributes of the subclass and the superclass[es]

joined-subclass assumes a table per subclass (i.e. attributes of the class and each its subclass are stored in different tables). (#10.1.2 in the same reference).

If you try to mix them how would hibernate know whether to look for one talbe or multiple tables?

I belive this is the reason the XSD allows yo to define either join and subclass OR joined-subclass OR union-subclass: ((join*,subclass*)|joined-subclass*|union-subclass*),


You can try to full the parser by defining each subclass in a different mapping file:

<hibernate-mapping package="...">
<subclass
name="com.mypackage.MySubClass"
extends ="com.mypackage.MySuperClass">
...
</subclass>
</hibernate-mapping>

another file:

<hibernate-mapping package="...">
<joined-subclass
name="com.mypackage.MyJoinedSubClass"
table="my_joinedsubclass_table"
extends ="com.mypackage.MySuperClass">
...
</joined-subclass>
</hibernate-mapping>



But I doubt it will work because of the above concern...


Dmitri


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 10:42 am 
Newbie

Joined: Fri Aug 05, 2005 7:26 am
Posts: 17
Location: Santa Barbara d´Oeste SP Brasil
Thanks nathanmoon.

We were making confusion with tags here....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 6:47 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Use <join in <subclass to mix both strategies

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: Using joined-subclass and suclass
PostPosted: Wed Oct 14, 2009 9:39 am 
Newbie

Joined: Mon Oct 12, 2009 6:07 am
Posts: 7
I am using join inside subclass but Now I need to defins the mapping for list inside join tag,

which hibernate does not allow. Can you help me in this?

<subclass name="foo">
<join table="foo">

<key..
<property..
<list???????
</join>
</subclass>


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

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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.