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.