Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Hibernate and XDoclet – How to generate Hibernate Mapping Files with XDoclet Hibernate and XDoclet – How to generate

Doclet – How to generate Hibernate Mapping Files with XDoclet

Table per hierarchy


Mapping in superclass Mapping in subclass Many-to-Many
/** /** If collection is not indexed (e.g. Set) then drop the @hibernate.collection-index
*@hibernate.class * @hibernate.subclass /**
*@hibernate.discriminator */ * @hibernate.list
* column="discriminator" * table="students_in_course"
*/ * cascade="save-update"
Table per subclass * @hibernate.collection-many-to-many
Mapping in superclass Mapping in subclass * column="fk_course"
/** /** * class="tutorial.manytomany.Course"
*@hibernate.class * @hibernate.joined-subclass * @hibernate.collection-key
*/ * @hibernate.joined-subclass-key * column="fk_student"
* column="pet" * @hibernate.collection-index
*/ * column="course_index"
*/
Table per concrete class
Mapping in concrete classes Component
/** Component owner. Component: No id property required. Just
* @hibernate.class map the persistent properties as in any
*/ other class.
One-to-One with primary key /** /**
The primary key of the one-to-one property is used -> use foreign key id generator * @hibernate.component * @hibernate.property
/** */ */
* @hibernate.id Property
* generator-class="foreign" A property (e.g. String, char, Long, …) Specify column details
* @hibernate.generator-param /** /**
* name="property" * @hibernate.property * @hibernate.column
* value="name of one-to-one * type=”a type” * sql-type=”a type”
* property" * length=”10” * column=”foo”
*/ */ */
A property (e.g. String, char, Long, …)
/** /**
* @hibernate.one-to-one * @hibernate.property
*/ * type=”a type”
One-to-One with foreign key * length=”10”
Represented with many-to-one */
/** ID
* @hibernate.many-to-one /**
* unique="true" * @hibernate.id
*/ * column="ID"
One-to-Many * generator-class="hilo"
If collection is not indexed (e.g. Set) then drop the @hibernate.collection-index * unsaved-value="null"
/** */
* @hibernate.list Composite ID
* cascade="save-update" The ID property
* @hibernate.collection-one-to-many /**
* class="class in collection" * @hibernate.id
* @hibernate.collection-index * column="ID"
* column="MANY_INDEX" * unsaved-value="any"
* @hibernate.collection-key */
* column="FK_ONE" When mapping collections
*/ * @hibernate.collection-key
* @hibernate.collection-key-column
* name="column_1"
* @hibernate.collection-key-column
* name="column_2"
Optimistic Locking
Version property (recommended). Timestamp
/** /**

Page 1/3 Version: 0.9 pascal@downside.ch Page 2/3 Version: 0.9 pascal@downside.ch
Hibernate and XDoclet – How to generate Hibernate Mapping Files with XDoclet

* @hibernate.version * @hibernate.timestamp
* unsaved-value="null" * unsaved-value="null"
*/ */

Page 3/3 Version: 0.9 pascal@downside.ch

You might also like