-->
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: mapping problem
PostPosted: Thu Mar 17, 2005 6:37 am 
Newbie

Joined: Thu Jan 06, 2005 12:55 am
Posts: 4
2.1:

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

<hibernate-mapping package="com.oqpc.web.valueobjects">
<class
name="ExpNote"
table="expnote"
discriminator-value="null"
lazy="true"
polymorphism="explicit"
>
<id
name="expNoteID"
column="expNoteID"
type="long"
>
<generator class="identity"/>
</id>

<discriminator column="legType" type="string"/>


<property
name="explainedID"
column="explainedID"
type="long"

/>
<property
name="numPages"
column="numPages"
type="integer"
not-null="false"
/>
<many-to-one name="file"
class="File"
column="fileID"
cascade="all"
unique="true"
/>

<subclass
name="ExpNoteBill"
discriminator-value="bill"
lazy="true"
>
<set name="addendums" cascade="save-update" inverse="true" lazy="true">
<key column="expNoteID"/>
<one-to-many class="Addendum"/>
</set>
</subclass>

<subclass
name="ExpNoteSL"
discriminator-value="sl"
lazy="true"
>
</subclass>

<subclass
name="ExpNoteAinc"
discriminator-value="ainc"
lazy="true"
>
</subclass>

</class>

</hibernate-mapping>


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

<hibernate-mapping package="com.oqpc.web.valueobjects">
<class
name="Ainc"
table="ainc"
>
<id
name="aincID"
type="long"
column="aincID"
>
<generator class="identity"/>
</id>

<property
name="numPage"
column="numPage"
type="integer"
/>

<many-to-one name="bill"
class="Bill"
column="billID"
unique="true"
/>

<many-to-one name="file"
class="File"
column="fileID"
unique="true"
/>

<set name="aincExpNotes" cascade="save-update" lazy="true">
<key column="explainedID"/>
<one-to-many class="ExpNoteAinc"/>
</set>

</class>

<query name="getAincs"><![CDATA[
from Ainc ainc left join fetch ainc.file left join fetch ainc.bill left join fetch ainc.aincExpNotes expNotes left join fetch expNotes.file
]]></query>

</hibernate-mapping>
:



mySQL 4:

I've been stuck on this one for a couple of days and it has baffled me and other hibernate users I know. The problem goes like this:

In my hibernate mapping model I have two classes Ainc and ExpNote. I've listed the mapping docs below. ExpNotes has three subclasses ExpNoteAinc, ExpNoteBill, ExpNoteSL. There is a one-to-many relationship between Ainc and ExpNotesAinc. However when I retrieve the set of aincExpNotes I get all ExpNotes when I only wanted ExpNoteAinc objects. In Ainc.hbm.xml I've mapped the set as:

<set name="aincExpNotes" cascade="save-update" lazy="true">
<key column="explainedID"/>
<one-to-many class="ExpNoteAinc"/>
</set>

Which has spedified class="ExpNoteAinc", but it seems that the set is still not being limited to the subclass. I've read Hibernate in Action and this seems to be the suggested way to do this. Can you see anything wrong with my mapping that is causing all ExpNote objects (the parent class) to be returned instead of just the subclass ExpNoteAinc objects.


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