Hibernate supports any kind of type provided that you define and implement the appropriate property value will be lazily fetched from the database once a lazy property of the entity is accessed for the first time.
The recommended alternative is to use the projection capability of JP-QL (Java Persistence Query Language) or Criteria queries.
JPA support property mapping of all basic types supported by Hibernate (all basic Java types , their respective wrappers and serializable classes).
Hibernate Annotations support out of the box enum type mapping either into a ordinal column (saving the enum ordinal) or a string based column (saving the enum string representation): the persistence representation, defaulted to ordinal, can be overridden through the property example.
A JPA 2 XML descriptor syntax for overriding is defined as well).
Their mappings are defined through JDK 5.0 annotations instead of files.
Annotations can be split in two categories, the logical mapping annotations (describing the object model, the association between two entities etc.) and the physical mapping annotations (describing the physical schema, tables, columns, indexes, etc).
We will mix annotations from both categories in the following code examples. You favorite IDE can auto-complete annotations and their attributes for you (even without a specific "JPA" module, since JPA annotations are plain JDK 5 annotations).
A good an complete set of working examples can be found in the Hibernate Annotations test suite itself: most of the unit tests have been designed to represent a concrete example and be a source of inspiration for you.
You can get the test suite sources in the distribution.
column, and the entity manager will use it to detect conflicting updates (preventing lost updates you might otherwise see with the last-commit-wins strategy).
The version column may be a numeric (the recommended solution) or a timestamp.