-->
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.  [ 4 posts ] 
Author Message
 Post subject: composite id with different class
PostPosted: Thu Apr 07, 2005 3:13 pm 
Beginner
Beginner

Joined: Fri Feb 04, 2005 2:44 pm
Posts: 25
Location: Buffalo, NY
Ok, so I have a mapping like this where there is a composite id. I use the separate class (DogID) for the primaray key. This works great with the load function (ex. load(Dog, DogID)). But when I obtain an object from a Query, the ID elements (firstName, lastName, birthDate) don't get loaded. The non-key properties (age) do get loaded. Do I have to do something different?

<class name="Dog" table="DOG">

<composite-id class="DogID">
<key-property name="firstName"
column="firstName"
type="string"/>
<key-property name="lastName"
column="lastName"
type="string"/>
<key-property name="birthDate"
column="bday"
type="date"/>
</composite-id>

<property name="age" type="int">
<column name="age" sql-type="integer" not-null="true"/>
</property>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 07, 2005 5:29 pm 
Beginner
Beginner

Joined: Thu Mar 24, 2005 5:21 pm
Posts: 21
Try naming your composite-id, like:
Code:
<composite-id name="id" class="DogID">
...

HTH
Satish


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 08, 2005 8:33 am 
Beginner
Beginner

Joined: Fri Feb 04, 2005 2:44 pm
Posts: 25
Location: Buffalo, NY
Adding the name="id" causes an error:

Code:
08:31:05,609  INFO Binder:230 - Mapping class: Dog -> DOG
08:31:05,640 ERROR Configuration:255 - Could not compile the mapping document
net.sf.hibernate.PropertyNotFoundException: field not found: id
   at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:74)
   at net.sf.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:80)
   at net.sf.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:88)
   at net.sf.hibernate.util.ReflectHelper.getter(ReflectHelper.java:81)
   at net.sf.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:90)
   at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:287)
   at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1257)
   at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
   at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
   at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
   at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1018)
   at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:974)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:902)
   at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:888)
   at converter.ConvertToLegacy.convert(ConvertToLegacy.java:47)
   at converter.ConvertToLegacy.main(ConvertToLegacy.java:32)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 08, 2005 8:42 am 
Beginner
Beginner

Joined: Thu Mar 24, 2005 5:21 pm
Posts: 21
mmm - you seem to be using field access rather than going through the accessor method
The obvious question now is, are you sure your primary key attribute is called id ?
HTH
Satish


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