Quick Table of Contents
Hibernate Annotations
1. Java 1.5 only
Only Java 1.5 supports annotations. If you are using 1.4 you can use xdoclet to help generated your mapping files
http://annotations.hibernate.org/
2. Basic column mapping
unique column restraint
To specifiy an unique key constraint on a column use
@Column(unique=true)
Enumeration
Enums are saved as either text or ordinals depending on the underlying column.
Ignored or transient fields
To ignore the field, annotate it with @Transient so it will not be mapped by hibernate.
3. Cascade all-delete-orphan
The standard EJB annotations don't have the delete orphan option.
@OneToMany {cascade=CascadeType.ALL}
The above is from the javax.persistence package.
Instead we can still use the original Hibernate mapping attributes this way:
@org.hibernate.annotations.Cascade(
{org.hibernate.annotations.CascadeType.ALL,org.hibernate.annotations.CascadeType.DELETE_ORPHAN}
)

