1.

What are the best practices that hibernate recommends for persistent classes.

Answer»

There are following main rules of persistent classes, however, none of these rules are hard requirements.

  • All Java classes that will be persisted need a default constructor.

  • All classes should contain an ID in order to allow easy identification of your objects within Hibernate and the database. This property maps to the primary key column of a database table.

  • All attributes that will be persisted should be declared private and have getXXX and setXXX methods defined in the JavaBean style.

  • A central feature of Hibernate, proxies, depends upon the persistent class being either non-final, or the implementation of an interface that declares all public methods.

  • All classes that do not extend or implement some specialized classes and interfaces required by the EJB framework.



Discussion

No Comment Found