Hibernate Notes
- API
Core Interfaces
- Session
- SessionFactory
- Configuration
- Transaction
- Query and Criteria
Callback Interfaces
- Lifecycle
- Validatable
- Interceptor
- Configuration: XML and annotations
- Configuration: Managed vs. Unmanaged
- Object identity: identity vs. equality, primary keys (natural and surrogate keys)
- Object model
Entity vs. value types
- entity has its own database identity (primary key value)
- value type has no database identity; is embedded in row of owning entity (except collections)
Components of classes
- allows separate class to be value object - lifecycle dependent on owning class
- Can be bidirectional (using "parent" element, but usually unidirectional
Mapping of inheritance
- Table per concrete class
- Table per class hierarchy
- Table per subclass
Associations
- Unidirection <many-to-one> : simplest, reference foreign key in owned class definition
- Bidirectional <many-to-one>,<one-to-many> : use <set> with child <one-to-many> and child <key> into owned class (also needs "inverse" attribute on <set> element)