JavaOne 2008 - The Java Persistance API 2.0

6:49 am Java

The session “The Java Persistence API 2.0″ was presented by Linda DeMichiel, SUN Microsystems. DeMichiel presented some of the features of JSR 317.  These features include more flexible modeling, expanded object relational mapping, additions to the query language, a criteria API, database hints, and validation support.

The Java Persistence API uses annotations in the Java code instead of XML configuration files.  Collections of basic types (Strings, Integers, etc.) can be expressed with the @ElementCollection annotation, and are stored in a collection table.  Collections of embeddable types also use the @ElementCollection annotation, but can be customize with the @AttributeOverride annotation.

Embeddable relationships can be expressed with the annotations @ManyToOne, @OneToOne, @OneToMany, and @ManyToMany and customized with @AssociationOverride annotation.

Ordered lists that are not persistent can use the @OrderBy annotation.  If however, you want to the ordering to persist, you would use the @OrderColumn annotation.

In the 2.0 spec, maps have been generalized both the keys and values can now be basic types, embeddables, or entities.

Automatic orphan deletion was added for related entities logically linked to a parent.  When the parent is deleted so are the children.  It is no longer necessary to specify “cascade=REMOVE”.

The query language has been expanded to include functions in the SELECT list, new modeling enhancements, and restricted polymorphism.

Leave a Comment

Your comment

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.