-->
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 collection of value types
PostPosted: Tue Aug 09, 2005 6:35 pm 
Newbie

Joined: Tue May 31, 2005 8:19 pm
Posts: 16
Location: San Francisco, CA
Hibernate 3.0.5

I have a class List that has a collection of ListValue objects. Based upon all of my reading, I decided that it is reasonable to map this collection of ListValue objects as a value type, as follows, using an <idbag> since the legacy database uses surrogate key for the ListValues table.

<class name="List" table="List">
<id name="id" type="long">
<column name="ListID" not-null="true"/>
<generator class="identity"/>
</id>
<property name="listName" type="string" column="ListName" not-null="true">
<property name="numericKey" type="boolean" column="NumericKey"/>
<idbag name="listValues" table="ListValues">
<collection-id type="Long" column="ID">
<generator class="sequence"/>
</collection-id>
<key column="ListID"/>
<composite-element class="ListValue">
<property name="valueKey" column="ValueKey"/>
<property name="valueDesc" column="ValueDesc"/>
<property name="orderId" column="OrderID"/>
</composite-element>
</idbag>
</class>

The problem is that I want to retrieve List objects with their ListValue objects ordered in more than one way. So I don't want to put an "order-by" in the <idbag> in the class mapping because there is no single ordering that applies for all retrievals. Instead, I am doing the ordering in queries, such as the following:

<query name="GenericListValueQuery"><![CDATA[
select new LabelValueBean(lv.ValueDesc, lv.ValueKey)
from List list
join list.listValues lv
where list.listname = :listName
order by lv.valueDesc
]]></query>

However, this results in a MappingException: class ListValue not found while l\ooking for property: valueKey

I believe this is because the ListValue class is not mapped. Only the List class is mapped, and the ListValue class is mapped as a collection of value types in the List class mapping. From the docs, it does not appear to me that the table containing the collection of value types should be explicity mapped, or ?

So how can I execute various queries to obtain a List with its ListValue objects in different orders ?
Should I scrap the collection of value type approach and just go with entity association mapping, even though the relationship suggests a collection of value types ?

thx.


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.