JAC project
AOPSYS
CEDRIC & LIP6 labs

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. Hence, this is a bit different from the other persistence aspect found in the JAC distribution (org.objectweb.jac.aspects.persistence) where reflection is used 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 interface contains 4 configuration methods: registerPersistentClass, initStorage, registerPersistentObject, delimitPersistentSession.

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

/** Declare a class to be persistent. */
registerPersistentClass User;

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

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

/**
 * 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 User.test1()
 */
delimitPersistentSession s0 User ".*" "test1.*" User ".*" "test1.*";

Related Documentation

For overviews, sources, tutorials, examples, guides, and tool documentation, please see:


Contact JAC development team:
Renaud Pawlak
Lionel Seinturier
Laurent Martelli