O'Reilly logo

Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications by Mick Knutson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Understanding @CollectionTable

The new @CollectionTable annotation specifies the table that is used for the mapping of collections of basic or embeddable types. This can be applied to the collection-valued field or property in an Entity Class. The embeddable objects are not stored in the embedded source object's table, but stored in a separate collection table. This is similar to a OneToMany, except the target object is an embeddable object instead of an @Entity. This allows collections of simple objects to be easily defined, without requiring the simple objects to define an ID or ManyToOne inverse mapping.

There are limitations to the ElementCollection instead of a OneToMany relationship. The target collection object cannot be queried, persisted, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required