P. 1
Hibernate Reference

Hibernate Reference

|Views: 1,008|Likes:

More info:

Published by: Vinod Kumar Kompalli on Oct 28, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Collections of components are supported (eg. an array of type Name). Declare your component collection by re-
placing the tag with a tag.

Note: if you define a Set of composite elements, it is very important to implement equals() and hashCode()

Composite elements may contain components but not collections. If your composite element itself contains
components, use the tag. This is a pretty exotic case - a collection of compon-

Component Mapping

Hibernate 2.1.7


ents which themselves have components. By this stage you should be asking yourself if a one-to-many associ-
ation is more appropriate. Try remodelling the composite element as an entity - but note that even though the
Java model is the same, the relational model and persistence semantics are still slightly different.

Please note that a composite element mapping doesn't support null-able properties if you're using a . Hi-
bernate has to use each columns value to identify a record when deleting objects (there is no separate primary
key column in the composite element table), which is not possible with null values. You have to either use only
not-null properties in a composite-element or choose a , , or .

A special case of a composite element is a composite element with a nested element. A map-
ping like this allows you to map extra columns of a many-to-many association table to the composite element
class. The following is a many-to-many association from Order to Item where purchaseDate, price and

quantity are properties of the association:


Even ternary (or quaternary, etc) associations are possible:


Composite elements may appear in queries using the same syntax as associations to other entities.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->