[Hibernate] "order-by" attribute on <bag> requires SortedSet implementation?
- From: Jim Garrison <jhg@xxxxxxxxxxxxxxx>
- Date: Mon, 12 Mar 2007 09:56:48 -0500
I have the following collection:
...
<bag name="comments" table="CR_COMMENT" order-by="CREATE_TS asc">
<key column="REQ_ID" />
<composite-element class="Comment">
<property name="createTs" column="CREATED_DATE"
type="calendar" access="field"
update="false" insert="false"
generated="always" />
<property name="sectionId" column="SECTION_ID" />
<property name="userId" column="USER_ID" />
<property name="text" column="TEXT"/>
</composite-element>
</bag>
...
defined in the Java class as
private Collection comments = new ArrayList();
because all the examples in JPH show bags implemented as
Collection interfaces backed by ArrayLists. At runtime I
get:
08:43:42,598 ERROR org.hibernate.property.BasicPropertyAccessor:94 -
IllegalArgumentException in class: om.wholefoods.ittoolkit.ws.ccf.Request,
setter method of property: comments
08:43:42,598 ERROR org.hibernate.property.BasicPropertyAccessor:98 -
expected type: java.util.SortedSet, actual value:
org.hibernate.collection.PersistentBag
This makes sense, because the order-by attribute implies that
some sort of ordered iterator will be required. However, won't
substituting a SortedSet for the ArrayList will cause the
collection to use Set semantics (no duplicate) instead of
"bag" semantics (duplicates allowed)?
Or, does Hibernate do something under the covers to preserve
the bag semantics?
.
- Follow-Ups:
- Prev by Date: Newbie question: Importing .csv data into Java DB tables
- Next by Date: Re: [Hibernate] "order-by" attribute on <bag> requires SortedSet implementation?
- Previous by thread: Newbie question: Importing .csv data into Java DB tables
- Next by thread: Re: [Hibernate] "order-by" attribute on <bag> requires SortedSet implementation?
- Index(es):