-->
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: composite-element and a nested array?
PostPosted: Tue Feb 03, 2004 6:15 pm 
Newbie

Joined: Tue Feb 03, 2004 5:20 pm
Posts: 2
I have two tables, A & B, along with their association table, A_B. Table A_B has extra properties in it, so I'm using a composite-element to take care of those.

However, one of those extra properties is an integer array (in the Java object). I've tried to nest a set or an array within the composite-element, something like this:

Code:
<set name="ab" table="A_B" lazy="false" inverse="false" cascade="none" sort="unsorted">
  <key column="A_id"/>
  <composite-element class="org.A_B">
    <property name="name"/>
    <set name="intArray" lazy="false" inverse="false" cascade="all" sort="unsorted">
      <key column="ABLink_id"/>
      <one-to-many class="something"/>
    </set>
    <many-to-one name="B" class="org.B" cascade="none" outer-join="auto" update="true" insert="true" column="B_id"/>
  </composite-element>
</set>


But hibernate doesn't like that. It gives the following error:

Code:
org.xml.sax.SAXParseException: The content of element type "composite-element" must match "(parent?,(property|many-to-one|nested-composite-element)*)".


I realize that with the example I've given, I couldn't exactly use an int - it would have to be some other kind of object. That's a lesser problem.

Any ideas on how I can get the array into the composite element? Or another way I could handle it?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 6:21 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Map A_B to a real entity instead of a pass-by-value type (composite) and use two one-to-many associations from A to A_B and B to A_B.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 7:09 pm 
Newbie

Joined: Tue Feb 03, 2004 5:20 pm
Posts: 2
Perfect. Thank you very much.


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