-->
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.  [ 2 posts ] 
Author Message
 Post subject: Collection of components with inheritance
PostPosted: Mon Mar 21, 2005 7:11 am 
Newbie

Joined: Mon Mar 08, 2004 4:10 am
Posts: 6
Hibernate version:Hibernate v2.1.6

Name and version of the database you are using:DB2 v8.2

I want to use collection of components with inheritance. My mapping document is below:
------------------------------------------
<class name="Bar" discriminator-value="AbstractBar" table="BAR">
<id column="ID" name="id" type="long">
<generator class="identity"></generator>
</id>
<discriminator column="TYPE" type="string" not-null="true"/>
<subclass name="AsilBar" discriminator-value="AsilBar">
<one-to-one name="xxx" class="Xxx" constrained="false" />
<one-to-one name="yyy" class="Yyy" constrained="false" />
<list name="barStates" lazy="true" table="BAR_STATE">
<key column="BAR_ID"/>
<index column="POSITION"/>
<composite-element class="BarState"/>
</list>
</subclass>
</class>

<class name="BarState" discriminator-value="AbstractBarState" table="BAR_STATE">
<id column="ID" name="id" type="long">
<generator class="increment"></generator>
</id>
<discriminator column="STATE" type="string" not-null="true"/>
<property name="notes" type="string" column="NOTE"/>
<subclass name="FirstState" discriminator-value="FirstStateDisc">
</subclass>
<subclass name="SecondState" discriminator-value="SecondStateDisc">
</subclass>
</class>
---------------------------------------------
Domain Classes:

public class Bar{
protected java.lang.Long id;
protected String entranceType;
// accessor and mutator
}

public class AsilBar extends Bar{
private Xxx xxx;
private Yyy yyy;
private List barStates = new ArrayList();
// accessor and mutator
}

public class BarState{
protected java.lang.Long id;
protected String state;
protected String notes;
// accessor and mutator
}

public class FirstState extends BarState{
}

public class SecondState extends BarState{
}
-------------------------------------------------------
When I want to find a Bar with its BarStates, I can take Bar but BarStates of this Bar can't be taken from database. What is the problem? Is there any wrong way in my mappings?


Top
 Profile  
 
 Post subject: Collection of components with inheritance
PostPosted: Wed Mar 23, 2005 5:59 am 
Newbie

Joined: Mon Mar 08, 2004 4:10 am
Posts: 6
Is there any idea that can help me? My problem is I can take Bar object but I can't reach the related BarState collection(the collection is null). How can I solve this problem?

Hibernate version:Hibernate v2.1.6

Name and version of the database you are using:DB2 v8.2

I want to use collection of components with inheritance. My mapping document is below:
------------------------------------------
<class name="Bar" discriminator-value="AbstractBar" table="BAR">
<id column="ID" name="id" type="long">
<generator class="identity"></generator>
</id>
<discriminator column="TYPE" type="string" not-null="true"/>
<subclass name="AsilBar" discriminator-value="AsilBar">
<one-to-one name="xxx" class="Xxx" constrained="false" />
<one-to-one name="yyy" class="Yyy" constrained="false" />
<list name="barStates" lazy="true" table="BAR_STATE">
<key column="BAR_ID"/>
<index column="POSITION"/>
<composite-element class="BarState"/>
</list>
</subclass>
</class>

<class name="BarState" discriminator-value="AbstractBarState" table="BAR_STATE">
<id column="ID" name="id" type="long">
<generator class="increment"></generator>
</id>
<discriminator column="STATE" type="string" not-null="true"/>
<property name="notes" type="string" column="NOTE"/>
<subclass name="FirstState" discriminator-value="FirstStateDisc">
</subclass>
<subclass name="SecondState" discriminator-value="SecondStateDisc">
</subclass>
</class>
---------------------------------------------
Domain Classes:

public class Bar{
protected java.lang.Long id;
protected String entranceType;
// accessor and mutator
}

public class AsilBar extends Bar{
private Xxx xxx;
private Yyy yyy;
private List barStates = new ArrayList();
// accessor and mutator
}

public class BarState{
protected java.lang.Long id;
protected String state;
protected String notes;
// accessor and mutator
}

public class FirstState extends BarState{
}

public class SecondState extends BarState{
}
-------------------------------------------------------
When I want to find a Bar with its BarStates, I can take Bar but BarStates of this Bar can't be taken from database. What is the problem? Is there any wrong way in my mappings?


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