4.2.5. Declare Optional Accessors and Mutators for Persistent Fields
Cat
declares accessor methods for all its persistent fields. Many other ORM tools directly persist instance variables. It is better to provide an indirection between the relational schema and internal data structures of the class. By default, Hibernate persists JavaBeans style properties and recognizes method names of the form getFoo
, isFoo
and setFoo
. If required, you can switch to direct field access for particular properties.
Properties need not be declared public - Hibernate can persist a property with a default,
protected
or private
get / set pair.