-->
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: One-to-one relationship with (non-class) composite keys
PostPosted: Fri May 05, 2006 9:24 am 
Newbie

Joined: Fri Dec 19, 2003 9:55 pm
Posts: 6
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
2.1.6

Mapping documents (abbreviated):

<class
name="com.acme.model.Member"
table="MEMBER"
>

<composite-id>
<key-property
name="memid1"
column="MEMID1"
type="java.lang.Long"
length="11"
/>
<key-property
name="memid2"
column="MEMID2"
type="java.lang.String"
length="22"
/>
</composite-id>

<one-to-one
name="memberDetail"
class="com.acme.model.MemberDetail"
outer-join="auto"
/>
</class>


<class
name="com.acme.model.MemberDetail"
table="MEMBER_DETAIL"
>

<composite-id>
<key-property
name="memid1"
column="MEMID1"
type="java.lang.Long"
length="11"
/>
<key-property
name="memid2"
column="MEMID2"
type="java.lang.String"
length="22"
/>
</composite-id>

<one-to-one
name="member"
class="com.acme.Member"
outer-join="auto"
constrained="true"
/>
</class>


Full stack trace of any exception that occurs:
net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.acme.model.MemberDetail.memid1
java.lang.IllegalArgumentException: object is not an instance of declaring class


Name and version of the database you are using:
Oracle9i

Problem description:

I have a one-to-one relationship between Member and MemberDetail. The entities are related by a composite-key field. The mapping documents have been auto-generated using Middlegen and hibernate tools.

I don't have any classes that represents the composite key ids in my domain model. This works fine for all other kinds of relationships where composite keys are involved, but I get an exception when I try to fetch all objects of type Model (see exception description above).

Can anybody see what's going wrong here? It seems to me that hibernate assumes that there is just one key-field.. Is there a way to set specify explicitly which key fields are to be used in the one-to-one mapping? What are my options for a workaround?

Very thankful for any input on this. Thanks for your attention.


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.