Description :
i want to know how can we write a component with composite-id, for example the following documents mapping...
[b]Hibernate version:
2.1.6
Mapping documents:
Bar.hbm.xml :
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="filters">
<class name="test.Bar" table="BAR">
<composite-id>
<key-property name="nom" column="nom" type="int" />
<key-property name="prenom" column="prenom" type="int" />
<key-many-to-one name="id" class="test.Foo" column="CODE_FOO"/>
</composite-id>
<property name="email" type="string" column="email" />
</class>
</hibernate-mapping>
Foo.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="filters">
<class name="test.Foo" table="Foo">
<id
name="id"
type="int"
column="CODE_FOO">
<generator class="native"/>
</id>
<property
name="nom"
column="NAME"
type="string"
/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Buildfile: C:\java\eclipse\workspace\test\build.xml
codegen:
[hbm2java] Processing 2 files.
[hbm2java] Building hibernate objects
[hbm2java] 21:25:13,484 WARN BasicRenderer:404 - No properties has been marked as being used in equals/hashcode for Bar. Using object identifier which is RARELY safe to use! See
http://hibernate.org/109.html
BUILD SUCCESSFUL
Total time: 1 second
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: