October 2006
Intermediate to advanced
880 pages
22h 11m
English
The Hibernate Annotations package supports nonstandard annotations for the mapping of collections that contain value-typed elements, mainly org.hibernate.annotations.CollectionOfElements. Let's walk through some of the most common scenarios again.
The following maps a simple collection of String elements:
@org.hibernate.annotations.CollectionOfElements(
targetElement = java.lang.String.class
)
@JoinTable(
name = "ITEM_IMAGE",
joinColumns = @JoinColumn(name = "ITEM_ID")
)
@Column(name = "FILENAME", nullable = false)
private Set<String> images = new HashSet<String>();
The collection table ITEM_IMAGE has two columns; together, they form the composite primary key. Hibernate ...