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.
|
|