emmanuel wrote:
If you have an embedded composite PK using a class PK,
Code:
public Man {
public ManPk id;
...
}
use @EmbeddedId (have a look at the doc for more infos)
On the contrary, if your class has embedded id properties refering a ManPk (which is the purpose of @IdClass)
Code:
public Man {
public String manFirstName;
public String manLastName;
...
}
public ManPk implements Serializable {
...
}
Then you can't map it yet, sorry :-(
All my project that uses hibernate 2.x use separate PK classes, and I now want to migrate to Hibernate 3 with annotations. Well, i see that i will need to wait for the final version. For your undestanding one of my my .hbm.xml is bellow, I think that the composite-id tag will be replaced by the @IdClass annotation right ?
Anyway, thanks for the attention.
<hibernate-mapping>
<class
name="br.com.venus.model.valueobjects.Menu_profileVO"
table="MENU_PROFILE"
dynamic-update="false"
dynamic-insert="false"
>
<composite-id
name="pk"
class="br.com.venus.model.valueobjects.Menu_profileKeyVO"
>
<key-property
name="id_menu"
type="integer"
column="id_menu"
/>
<key-property
name="id_permission"
type="integer"
column="id_permission"
/>
<key-property
name="id_profile"
type="integer"
column="id_profile"
/>
</composite-id>
<many-to-one
name="menu"
class="br.com.venus.model.valueobjects.MenuVO"
cascade="none"
outer-join="auto"
update="false"
insert="false"
access="property"
column="id_menu"
/>
<many-to-one
name="permission"
class="br.com.venus.model.valueobjects.PermissionVO"
cascade="none"
outer-join="auto"
update="false"
insert="false"
access="property"
column="id_permission"
/>
<property
name="permission_value"
type="string"
update="true"
insert="true"
access="property"
column="permission_value"
length="50"
not-null="false"
unique="false"
/>
<property
name="status"
type="integer"
update="true"
insert="true"
access="property"
column="status"
length="1"
not-null="false"
unique="false"
/>
<many-to-one
name="profile"
class="br.com.venus.model.valueobjects.ProfileVO"
cascade="none"
outer-join="auto"
update="false"
insert="false"
access="property"
column="id_profile"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Menu_profileVO.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>