-->
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: problem with composite-index
PostPosted: Thu Mar 18, 2004 8:39 am 
Newbie

Joined: Thu Mar 18, 2004 8:22 am
Posts: 2
Location: Brasil
hi,

i'm trying to make a qualified composite association between two classes.

I have a class named CD mapped of the following form:

<hibernate-mapping>
<class
name="Cd"
table="Cd"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="idCd"
column="COD_CD"
type="long"
unsaved-value="any"
>
<generator class="sequence">
<param name="sequence">SQ_CD_01</param>
</generator>
</id>

<property
name="ano"
type="int"
update="true"
insert="true"
column="ano"
/>

<property
name="gravadora"
type="java.lang.String"
update="true"
insert="true"
column="gravadora"
/>

<property
name="nome"
type="java.lang.String"
update="true"
insert="true"
column="nome"
not-null="true"
unique="true"
/>

<set
name="musicas"
lazy="false"
inverse="false"
cascade="all-delete-orphan"
sort="unsorted"
order-by="COD_MUSICA asc"
>

<key
column="COD_CD"
/>

<one-to-many
class="Musica"
/>
</set>

<one-to-one
name="emprestimo"
class="Emprestimo"
cascade="all"
outer-join="auto"
constrained="false"
/>

</class>

</hibernate-mapping>


--------------------------------------------------
and a have a class named ControladorEmprestimo:

<hibernate-mapping>
<class
name="ControladorEmprestimo"
table="ControladorEmprestimo"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="idControladorEmprestimo"
column="COD_CONTROLADOR_EMPRESTIMO"
type="long"
unsaved-value="any"
>
<generator class="sequence">
<param name="sequence">SQ_EMPRESTIMO_01</param>
</generator>
</id>

<map name="catalogoCd" lazy="false" sort="unsorted"
inverse="false" cascade="all-delete-orphan">

<key column="COD_CONTROLADOR_EMPRESTIMO"/>


<composite-index class="Cd">
<key-property name="nome" type="string" column="nome"/>
<key-property name="gravadora" type="string" column="gravadora"/>
</composite-index>

<one-to-many class="Cd" />

</class>

</hibernate-mapping>

---------------------------------------------------------------------------------
I need that the association catalogoCd can be mapped by a key containing the column name and the column gravadora.
I Think that it can be made with <composite-index>.
When hibernate try to call the getter method of name in cd class the following exception is generated:

net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of Cd.nome
....
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class

The hibernate version that i use is: 2.1.1

Tanks
Jean.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 19, 2004 6:53 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You"re mismatching the one-to-one use.
one-to-one means both side must share the same id. This is not possible in your case since you've added a sequence generator.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 20, 2004 6:38 pm 
Newbie

Joined: Thu Mar 18, 2004 8:22 am
Posts: 2
Location: Brasil
Thanks for help.
The problem was solved.


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