-->
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.  [ 3 posts ] 
Author Message
 Post subject: Question <join> to mix inheritance
PostPosted: Wed Mar 16, 2005 1:15 pm 
Newbie

Joined: Sat Feb 26, 2005 10:10 pm
Posts: 8
Hibernate version:3.0rc1

Mapping documents:


Code:
<class name="DocumentElement" table="DocumentElementTable">
        <id
            name="objId"
            column="objId"
            type="long">
            <generator class="native"/>
        </id>
        <discriminator column="type" type="string"/>
        <property name="status" column="status"/>
        <property name="lockedBy" column="locked_by"/>
        <property name="name" column="name"/>
        <property name="description" column="description"/>

    <subclass name="Header" extends="DocumentElement" discriminator-value="Header">
        <join table="XMLDoc">
            <key column="template_id"/>
[b]            <set name="entries" inverse="true" cascade="all">
                <key column="template_id"/>
                <one-to-many class="Entry"/>
            </set>[/b]        </join>
    </subclass>

    <subclass name="Entry" extends="DocumentElement" discriminator-value="Entry">
        <join table="Entry">
            <key column="entry_id"/>
            <property name="tagName" column="tagName"/>
            <property name="value" column="value"/>
        </join>
    </subclass>
</class>


Full stack trace of any exception that occurs:
[java] 08:34:58,404 ERROR XMLHelper:59 - Error parsing XML: XML InputStream
(61) The content of element type "join" must match "(subselect?,key,(property|ma
ny-to-one|component|dynamic-component|any)*,sql-insert?,sql-update?,sql-delete?)
".



I have a DocumentElement Parent class with two subclasses: Header and Entry. A Header can contain a list of Entry. I am mixing a table-per-hiearchy with table-per-subclass because the attributes for Entry may be many. I do not which to include it in the table for the hierarchy.

It seems like I can't use <set> in the <join>. I can probably get around this problem specifying a 1-N relationship but does it mean that I can load Collections when I use join? What's the reasoning behind this?

Thanks.

Theen-Theen


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 8:20 pm 
Newbie

Joined: Tue Feb 15, 2005 10:58 pm
Posts: 4
tcube,
I am having a very similiar problem even after following the examples in the docs.

I notice in your code, you have a <set ...> inside your <join..>. If you look at the 3.0 dtd, you can't put <set> within a <join>.

See: http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd

Are you using the 3.0 dtd in your mapping files? You don't show the top lines of your mapping file in the code you posted so I can't tell.

I hope that helps...if you got past this or have anymore insights, please reply. I am still having problems regardless of where I put my <property> and <set>. I have tried both under <subclass> and <join> but XMLHelper complains, even though the DTD says I can do what I am doing:

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

<hibernate-mapping>

<subclass name="MySubClass"
discriminator-value="CLASS1"
extends="MySuperClass">

<join table="MY_SUB_TABLE">
<key column="ID"/>
</join>

<property name="col1" type="long">
<column name="col1" not-null="true" />
</property>

<set name="details"
table="DETAIL"
cascade="all"
lazy="true"
inverse="true">
<key column="MY_SUBCLASS_ID"/>
<one-to-many class="Detail"/>
</set>

</subclass>

</hibernate-mapping>

Error parsing XML: XML InputStream(37) The content of element type "subclass" must match "(meta*,synchronize*,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array|query-list)*,join*,subclass*,loader?,sql-insert?,sql-delete?,sql-update?)".


Thx,
Eric


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 9:01 pm 
Newbie

Joined: Tue Feb 15, 2005 10:58 pm
Posts: 4
tcube,
I found my problem...I didn't relize when reading the DTD that order matters! I had to put the <join> tag BELOW the <property> and <set> tags.

HTH,
Eric


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.