com.googlecode.jpattern.orm.session
Interface ISession

All Known Subinterfaces:
ISessionSqlPerformer
All Known Implementing Classes:
ASession, DataSourceSession, JdbcTemplateSession, NullSession

public interface ISession

Author:
Francesco Cina 21/mag/2011 A connection wrapper object witch the detail of the real used connection object

Method Summary
 ITransaction beginTransaction()
          Open a new Transaction
 void close()
          Close the current session and release the connection to the database.
 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> object)
          Delete the objects from the database
<T> void
delete(T object)
          Delete one object from the database
<T> T
find(Class<T> clazz, Object idValue)
          Load a registered Object from the database
<T> T
find(Class<T> clazz, Object[] idValues)
          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
<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
 

Method Detail

beginTransaction

ITransaction beginTransaction()
                              throws OrmException
Open a new Transaction

Returns:
Throws:
OrmException

find

<T> T find(Class<T> clazz,
           Object idValue)
       throws OrmException
Load a registered Object from the database

Type Parameters:
T -
Parameters:
clazz - The Class of the object to load
idValue - the value of the identifying column of the object
Returns:
Throws:
OrmException

find

<T> T find(Class<T> clazz,
           Object[] idValues)
       throws OrmException
Load a registered Object from the database

Type Parameters:
T -
Parameters:
clazz - The Class of the object to load
idValues - an ordered array with the values of the identifying columns of the object
Returns:
Throws:
OrmException

save

<T> void save(T object)
          throws OrmException
Persist the new object in the database

Type Parameters:
T -
Parameters:
object -
Throws:
OrmException

save

<T> void save(List<T> objects)
          throws OrmException
Persist the new objects in the database

Type Parameters:
T -
Parameters:
objects - the objects to persist
Throws:
OrmException

update

<T> void update(T object)
            throws OrmException
Update the values of an existing object in the database

Type Parameters:
T -
Parameters:
object -
Throws:
OrmException

update

<T> void update(List<T> objects)
            throws OrmException
Update the values of the existing objects in the database

Type Parameters:
T -
Parameters:
objects - the objects to update
Throws:
OrmException

update

IUpdate update(Class<?> clazz)
               throws OrmException
Update the objects of a specific TABLE

Parameters:
clazz - the TABLE related Class
Throws:
OrmException

update

IUpdate update(Class<?> clazz,
               String alias)
               throws OrmException
Update the objects of a specific TABLE

Parameters:
clazz - the TABLE related Class
alias - The alias of the class in the query.
Throws:
OrmException

delete

<T> void delete(T object)
            throws OrmException
Delete one object from the database

Type Parameters:
T -
Parameters:
object -
Throws:
OrmException

delete

<T> void delete(List<T> object)
            throws OrmException
Delete the objects from the database

Type Parameters:
T -
Parameters:
objects - the objects to delete
Throws:
OrmException

delete

IDelete delete(Class<?> clazz)
               throws OrmException
Delete the objects of a specific table

Parameters:
clazz - the TABLE related Class
Throws:
OrmException

delete

IDelete delete(Class<?> clazz,
               String alias)
               throws OrmException
Delete the objects of a specific table

Parameters:
clazz - the TABLE related Class
alias - The alias of the class in the query.
Throws:
OrmException

findQuery

<T> IOrmQuery<T> findQuery(Class<T> clazz,
                           Class<?>... joinClasses)
                       throws OrmException
Create a new query

Type Parameters:
T -
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

<T> IOrmQuery<T> findQuery(Class<T> clazz,
                           String alias)
                       throws OrmException
Create a new query

Type Parameters:
T -
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

IOrmCustomQuery findQuery(String selectClause,
                          Class<?> clazz,
                          Class<?>... joinClasses)
                          throws OrmException
Create a new custom query

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

IOrmCustomQuery findQuery(String selectClause,
                          Class<?> clazz,
                          String alias)
                          throws OrmException
Create a new query

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

close

void close()
           throws OrmException
Close the current session and release the connection to the database.

Throws:
OrmException

sqlExecutor

ISqlExecutor sqlExecutor()
An executor to perform any kind of plain SQL statements.

Returns:

scriptExecutor

IScriptExecutor scriptExecutor()
                               throws OrmException
A script executor useful to execute multiple sql statement from files.

Returns:
Throws:
OrmException


Copyright © 2011. All Rights Reserved.