Package org.objectweb.jac.aspects.hibernate

Provides an aspect that allows to define persistent data.

See:
          Description

Class Summary
BeginPersistentSessionWrapper This wrapper delimits the begining of a persistent session.
EndPersistentSessionWrapper This wrapper delimits the end of a persistent session.
HibernateAC Persistence AC relying on Hibernate.
HibernateHelper This class acts as a gateway between the AC HibernateAC and the Hibernate 2.0 framework.
 

Package org.objectweb.jac.aspects.hibernate Description

Provides an aspect that allows to define persistent data. This aspect encapsulates the Hibernate framework.

Hibernate offers persistence over a DBMS using JDBC. Hibernate handles basic data types, collections, references. Hibernate offers a query language to fetch persistent objects according to some given criteria.

Hibernate imposes a number of constraints on the way you write your code:

  1. persistent classes must declare setters/getters for persistent fields
  2. persistent classes must provide a no-argument constructor
  3. a persistent descriptor (.xml) must be provided for each persistent class

Point 1. and 2. are related to the way business objects are written. This differs from the org.objectweb.jac.aspects.persistence.PersistenceAC that uses reflection to access fields. Hibernate thus imposes some overhead on the business developper (even if we could think of automatically generating setter/getter for all fields).

Point 3. is under the responsability of the aspect programmer that has to write this .xml file and the traditional .acc file for configuring the Hibernate persistence AC.

HibernateAC provides 4 configuration methods:

The typical usage scenario of this AC is illustrated below (the example can also be found in the org.objectweb.jac.samples.hibernate.Account application).

/** Declare a class (Account) to be persistent. */
registerPersistentClass Account;

/**
 * Create tables to hold data for persistent classes.
 * Only once if you want to keep data between two program runs
 * (Hibernate drops tables before creating them, even if they exist).
 */
initStorage ;

/** Tell which JAC objects (account0 & account1) are to be made persistent. */
registerPersistentObject account0;
registerPersistentObject account1;

/**
 * Delimit the Hibernate persistent session.
 * The session will begin after the 1st pointcut (parameters 2,3,4),
 * and end before the 2nd one (parameters 5,6,7).
 * -> here the session is around method Account.transfert()
 */
delimitPersistentSession s0 Account ".*" "transfert.*" Account ".*" "transfert.*";