Appendix A. Hibernate Types
Hibernate makes a fundamental distinction between two different kinds of data in terms of how they relate to the persistence service: entities and values.
An entity is something with its own independent existence, regardless of whether it’s currently reachable by any object within a Java virtual machine. Entities can be retrieved from the database through queries, and they must be explicitly saved and deleted by the application. (If cascading relationships have been set up, the act of saving or deleting a parent entity can also save or delete its children, but this is still explicit at the level of the parent.)
Values are stored only as part of the persistent state of an entity. They have no independent existence. They might be primitives, collections, enumerations, or custom user types. Since they are entirely subordinated to the entity in which they exist, they cannot be independently versioned, nor can they be shared by more than one entity or collection.
Notice that a particular Java object might be either an entity or a value—the difference is in how it is designed and presented to the persistence service. Primitive Java types are always values.
Basic Types
Here is a smattering of information about the built-in types, showing how they relate Java classes to SQL column types. We present samples of the variability between databases, but are not trying to show every variant; check out the source code for all the dialect implementations in org.hibernate.dialect ...
Get Harnessing Hibernate now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.