com.googlecode.jpattern.orm.session
Class ASession

java.lang.Object
  extended by com.googlecode.jpattern.orm.session.ASession
All Implemented Interfaces:
ISession, ISessionSqlPerformer
Direct Known Subclasses:
DataSourceSession, JdbcTemplateSession, NullSession

public abstract class ASession
extends Object
implements ISessionSqlPerformer

Author:
Francesco Cina 27/giu/2011

Constructor Summary
ASession(IOrmClassToolMap ormClassToolMap)
           
 
Method Summary
 IDelete delete(Class<?> clazz)
          Delete the objects of a specific table
 IDelete delete(Class<?> clazz, String alias)
          Delete the objects of a specific table
<T> void
delete(List<T> objects)
          Delete the objects from the database
<T> void
delete(T object)
          Delete one object from the database
<T> T
find(Class<T> clazz, Object value)
          Load a registered Object from the database
<T> T
find(Class<T> clazz, Object[] values)
          Load a registered Object from the database
<T> IOrmQuery<T>
findQuery(Class<T> clazz, Class<?>... joinClasses)
          Create a new query
<T> IOrmQuery<T>
findQuery(Class<T> clazz, String alias)
          Create a new query
 IOrmCustomQuery findQuery(String selectClause, Class<?> clazz, Class<?>... joinClasses)
          Create a new custom query
 IOrmCustomQuery findQuery(String selectClause, Class<?> clazz, String alias)
          Create a new query
protected  IOrmClassToolMap getOrmClassToolMap()
           
<T> void
save(List<T> objects)
          Persist the new objects in the database
<T> void
save(T object)
          Persist the new object in the database
 IScriptExecutor scriptExecutor()
          A script executor useful to execute multiple sql statement from files.
 ISqlExecutor sqlExecutor()
          An executor to perform any kind of plain SQL statements.
 IUpdate update(Class<?> clazz)
          Update the objects of a specific TABLE
 IUpdate update(Class<?> clazz, String alias)
          Update the objects of a specific TABLE
<T> void
update(List<T> objects)
          Update the values of the existing objects in the database
<T> void
update(T object)
          Update the values of an existing object in the database
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.googlecode.jpattern.orm.session.ISessionSqlPerformer
sqlPerformer
 
Methods inherited from interface com.googlecode.jpattern.orm.session.ISession
beginTransaction, close
 

Constructor Detail

ASession

public ASession(IOrmClassToolMap ormClassToolMap)
Method Detail

findQuery

public final <T> IOrmQuery<T> findQuery(Class<T> clazz,
                                        Class<?>... joinClasses)
                             throws OrmException
Description copied from interface: ISession
Create a new query

Specified by:
findQuery in interface ISession
Parameters:
clazz - The class of the object that will be retrieved by the query execution. The simple class name will be used as alias for the class
joinClasses - a list of class that will be added in the 'from' using comma separation. For every class the simple class name will be used as alias.
Returns:
Throws:
OrmException

findQuery

public final <T> IOrmQuery<T> findQuery(Class<T> clazz,
                                        String alias)
                             throws OrmException
Description copied from interface: ISession
Create a new query

Specified by:
findQuery in interface ISession
Parameters:
clazz - The class of the object that will be retrieved by the query execution.
alias - The alias of the class in the query.
Returns:
Throws:
OrmException

findQuery

public final IOrmCustomQuery findQuery(String selectClause,
                                       Class<?> clazz,
                                       Class<?>... joinClasses)
                                throws OrmException
Description copied from interface: ISession
Create a new custom query

Specified by:
findQuery in interface ISession
Parameters:
selectClause - the select clause of the query (do not use the "select" keyword)
clazz - The class of the object that will be retrieved by the query execution. The simple class name will be used as alias for the class
joinClasses - a list of class that will be added in the 'from' using comma separation. For every class the simple class name will be used as alias.
Returns:
Throws:
OrmException

findQuery

public final IOrmCustomQuery findQuery(String selectClause,
                                       Class<?> clazz,
                                       String alias)
                                throws OrmException
Description copied from interface: ISession
Create a new query

Specified by:
findQuery in interface ISession
Parameters:
selectClause - the select clause of the query (do not use the "select" keyword)
clazz - The class of the object that will be retrieved by the query execution.
alias - The alias of the class in the query.
Returns:
Throws:
OrmException

getOrmClassToolMap

protected final IOrmClassToolMap getOrmClassToolMap()

find

public final <T> T find(Class<T> clazz,
                        Object value)
             throws OrmException
Description copied from interface: ISession
Load a registered Object from the database

Specified by:
find in interface ISession
Parameters:
clazz - The Class of the object to load
value - the value of the identifying column of the object
Returns:
Throws:
OrmException

find

public final <T> T find(Class<T> clazz,
                        Object[] values)
             throws OrmException
Description copied from interface: ISession
Load a registered Object from the database

Specified by:
find in interface ISession
Parameters:
clazz - The Class of the object to load
values - an ordered array with the values of the identifying columns of the object
Returns:
Throws:
OrmException

save

public final <T> void save(T object)
                throws OrmException
Description copied from interface: ISession
Persist the new object in the database

Specified by:
save in interface ISession
Throws:
OrmException

save

public final <T> void save(List<T> objects)
                throws OrmException
Description copied from interface: ISession
Persist the new objects in the database

Specified by:
save in interface ISession
Parameters:
objects - the objects to persist
Throws:
OrmException

update

public final <T> void update(T object)
                  throws OrmException
Description copied from interface: ISession
Update the values of an existing object in the database

Specified by:
update in interface ISession
Throws:
OrmException

update

public final <T> void update(List<T> objects)
                  throws OrmException
Description copied from interface: ISession
Update the values of the existing objects in the database

Specified by:
update in interface ISession
Parameters:
objects - the objects to update
Throws:
OrmException

update

public final IUpdate update(Class<?> clazz)
                     throws OrmException
Description copied from interface: ISession
Update the objects of a specific TABLE

Specified by:
update in interface ISession
Parameters:
clazz - the TABLE related Class
Throws:
OrmException

update

public final IUpdate update(Class<?> clazz,
                            String alias)
                     throws OrmException
Description copied from interface: ISession
Update the objects of a specific TABLE

Specified by:
update in interface ISession
Parameters:
clazz - the TABLE related Class
alias - The alias of the class in the query.
Throws:
OrmException

delete

public final <T> void delete(T object)
                  throws OrmException
Description copied from interface: ISession
Delete one object from the database

Specified by:
delete in interface ISession
Throws:
OrmException

delete

public final <T> void delete(List<T> objects)
                  throws OrmException
Description copied from interface: ISession
Delete the objects from the database

Specified by:
delete in interface ISession
Throws:
OrmException

delete

public final IDelete delete(Class<?> clazz)
                     throws OrmException
Description copied from interface: ISession
Delete the objects of a specific table

Specified by:
delete in interface ISession
Parameters:
clazz - the TABLE related Class
Throws:
OrmException

delete

public final IDelete delete(Class<?> clazz,
                            String alias)
                     throws OrmException
Description copied from interface: ISession
Delete the objects of a specific table

Specified by:
delete in interface ISession
Parameters:
clazz - the TABLE related Class
alias - The alias of the class in the query.
Throws:
OrmException

scriptExecutor

public final IScriptExecutor scriptExecutor()
                                     throws OrmException
Description copied from interface: ISession
A script executor useful to execute multiple sql statement from files.

Specified by:
scriptExecutor in interface ISession
Returns:
Throws:
OrmException

sqlExecutor

public final ISqlExecutor sqlExecutor()
Description copied from interface: ISession
An executor to perform any kind of plain SQL statements.

Specified by:
sqlExecutor in interface ISession
Returns:


Copyright © 2011. All Rights Reserved.