-->
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: composite-id example, PLEASE
PostPosted: Fri Aug 13, 2004 12:56 pm 
Newbie

Joined: Fri Aug 13, 2004 12:06 pm
Posts: 15
Hibernate version:2.1

Mapping documents:needed

Code between sessionFactory.openSession() and session.close():needed

Full stack trace of any exception that occurs:n/a

Name and version of the database you are using:Pointbase Version: 4.4

Debug level Hibernate log excerpt:n/a


Can someone please give me a complete, simple example of a Hibernate mapping file, the JavaBeans classes generated and example usage for a set of classes, where one has a collection of the other and the one that is a collection has a composite id? I can't get mine to work and the Hibernate documentation is extremely lean on the composite-id section.

This is what I am trying to get to work, but I know it is wrong because I don't know how to use a composite-id. Each section is wrong as far as I know.

Thank you VERY much.:


Band bean's mapping:

<bag name="recordings" lazy="true" inverse="false"
cascade="none" order-by="BANDNAME">
<meta attribute="field-description">List of band's recordings.</meta>
<meta attribute="use-in-tostring">true</meta>
<key column="BANDNAME"/>
<one-to-many class="RecordingBean"/>
</bag>

Q: What is the correct way to use the composite-id from the RecordingBean below, in the mapping of the bag, above?


Recording bean mapping:

<composite-id>
<key-property name="bandname" type="string"
column="BANDNAME">
<meta attribute="field-description">Returns band's name.</meta>
<meta attribute="use-in-tostring">true</meta>
</key-property>
<key-property name="title" type="string" column="TITLE">
<meta attribute="field-description">Returns recording name.</meta>
<meta attribute="use-in-tostring">true</meta>
</key-property>
</composite-id>


This is how I try to load a recording:

RecordingBean rb = new RecordingBean(bandname, title);
try {
RecordingBean recording = (RecordingBean)
HibernateUtil.currentSession().load(RecordingBean.class, rb);
return recording;
} catch (Exception e) {
throw new PersistenceException("Could not retrieve.", e);
}

Q: How do you load a bean with a compsite id if you don't know or have its id?

A COMPLETE example would be a huge help. Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 14, 2004 4:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Look in Hibernate3 CVS, under test/org/hibernate/test/cid


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.