org.perfectjpattern.jee.integration.dao
Class HibernateSessionAdapter

java.lang.Object
  extended by org.perfectjpattern.core.structural.AbstractSurrogate<T,A>
      extended by org.perfectjpattern.core.structural.adapter.Adapter<ISession,org.hibernate.Session>
          extended by org.perfectjpattern.jee.integration.dao.HibernateSessionAdapter
All Implemented Interfaces:
InvocationHandler, IAdapter<ISession,org.hibernate.Session>, ISurrogate<ISession>

public final class HibernateSessionAdapter
extends Adapter<ISession,org.hibernate.Session>

Adapts Hibernate's Session to the JPA implementation-free PerfectJPattern's ISession definition

Version:
$Revision: 1.0 $Date: Feb 10, 2009 8:26:06 PM $
Author:
Giovanni Azua
 

Constructor Summary
HibernateSessionAdapter(org.hibernate.Session anAdaptee)
          Constructs a HibernateSessionAdapter from the Adaptee Session instance
 
Method Summary
 IQuery createNativeQuery(String aSqlString, Class<?> aPersistentClass)
           
 IQuery createQuery(String aSqlString)
           
<E> E
find(Class<E> aPersistentClass, Object anId)
           
 org.hibernate.Session getDelegate()
           
 ITransaction getTransaction()
           
protected  Object invokeUnderlying(Method aMethod, Object[] anArguments)
          Returns the result of the Method invocation.
<Id> Id
persist(Object anObject)
           
 void remove(Object anObject)
           
 void update(Object anObject)
           
 
Methods inherited from class org.perfectjpattern.core.structural.adapter.Adapter
getAdaptee, getTarget, setAdaptingStrategy
 
Methods inherited from class org.perfectjpattern.core.structural.AbstractSurrogate
equals, getComponent, getComponentClass, getUnderlying, hashCode, invoke
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.perfectjpattern.core.api.structural.ISurrogate
getComponent
 
Methods inherited from interface java.lang.reflect.InvocationHandler
invoke
 

Constructor Detail

HibernateSessionAdapter

public HibernateSessionAdapter(org.hibernate.Session anAdaptee)
                        throws IllegalArgumentException
Constructs a HibernateSessionAdapter from the Adaptee Session instance

Parameters:
anAdaptee - Adaptee Hibernate Transaction
Throws:
IllegalArgumentException
Method Detail

invokeUnderlying

protected Object invokeUnderlying(Method aMethod,
                                  Object[] anArguments)
                           throws Throwable
Returns the result of the Method invocation. This method has two main purposes:

Overrides:
invokeUnderlying in class Adapter<ISession,org.hibernate.Session>
Parameters:
aMethod - Method to invoke
anArguments - Array of input arguments for the Method to invoke
Returns:
result of the Method invocation
Throws:
Throwable

getTransaction

public ITransaction getTransaction()

find

public <E> E find(Class<E> aPersistentClass,
                  Object anId)

getDelegate

public org.hibernate.Session getDelegate()

createQuery

public IQuery createQuery(String aSqlString)

createNativeQuery

public IQuery createNativeQuery(String aSqlString,
                                Class<?> aPersistentClass)

remove

public void remove(Object anObject)

update

public void update(Object anObject)

persist

public <Id> Id persist(Object anObject)


Copyright © 2007-2009. All Rights Reserved.