fri.util.database.jpa.tree.hibernatesession
Class DbSessionHibernateImpl

java.lang.Object
  extended by fri.util.database.jpa.tree.hibernatesession.DbSessionHibernateImpl
All Implemented Interfaces:
DbSession

public class DbSessionHibernateImpl
extends java.lang.Object
implements DbSession

Hibernate Session (not JPA-compatible!) implementation of DbSession.

Author:
Fritz Ritzberger, 2013-08-24

Constructor Summary
DbSessionHibernateImpl(org.hibernate.Session session)
           
 
Method Summary
 void delete(java.lang.Object node)
          Deletes passed object from persistence.
 void executeUpdate(java.lang.String sqlCommand, java.lang.Object[] parameters)
          Executes an update or delete statement.
 void flush()
          Flushes all changes to database.
 java.lang.Object get(java.lang.Class<?> entityClass, java.io.Serializable id)
          Fast cached read of an object by identity (primary key).
 org.hibernate.Session getHibernateSession()
          Do not use.
 int queryCount(java.lang.String queryText, java.lang.Object[] parameters)
          Executes given query and returns the resulting count of found records.
 java.util.List<?> queryList(java.lang.String queryText, java.lang.Object[] parameters)
          Executes a query and returns its result list.
 void refresh(java.lang.Object node)
          Re-reads passed object from persistence.
 java.lang.Object save(java.lang.Object node)
          Save the passed object to persistence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbSessionHibernateImpl

public DbSessionHibernateImpl(org.hibernate.Session session)
Method Detail

get

public java.lang.Object get(java.lang.Class<?> entityClass,
                            java.io.Serializable id)
Description copied from interface: DbSession
Fast cached read of an object by identity (primary key).

Specified by:
get in interface DbSession
Parameters:
entityClass - the persistence class of the entity (POJO).
id - the primary key of the entity.
Returns:
the entity object with given primary key.

save

public java.lang.Object save(java.lang.Object node)
Description copied from interface: DbSession
Save the passed object to persistence.

Specified by:
save in interface DbSession
Parameters:
node - the object to save.

flush

public void flush()
Description copied from interface: DbSession
Flushes all changes to database. This is needed as some changes are not done via JPA objects but directly via JPQL.

Specified by:
flush in interface DbSession

refresh

public void refresh(java.lang.Object node)
Description copied from interface: DbSession
Re-reads passed object from persistence. This is needed as some changes are not done via JPA objects but directly via JPQL.

Specified by:
refresh in interface DbSession
Parameters:
node - the object to refresh.

delete

public void delete(java.lang.Object node)
Description copied from interface: DbSession
Deletes passed object from persistence.

Specified by:
delete in interface DbSession
Parameters:
node - the object to delete.

queryList

public java.util.List<?> queryList(java.lang.String queryText,
                                   java.lang.Object[] parameters)
Description copied from interface: DbSession
Executes a query and returns its result list.

Specified by:
queryList in interface DbSession
Parameters:
queryText - the JPQL text for the query.
parameters - the positional parameters for "?" place-holders in query text.
Returns:
the result list of the query.

queryCount

public int queryCount(java.lang.String queryText,
                      java.lang.Object[] parameters)
Description copied from interface: DbSession
Executes given query and returns the resulting count of found records. The query must be a select count(x) ... query.

Specified by:
queryCount in interface DbSession
Parameters:
queryText - the JPQL text for the query.
parameters - the positional parameters for "?" place-holders in query text.
Returns:
the number of records found by the query.

executeUpdate

public void executeUpdate(java.lang.String sqlCommand,
                          java.lang.Object[] parameters)
Description copied from interface: DbSession
Executes an update or delete statement.

Specified by:
executeUpdate in interface DbSession
Parameters:
sqlCommand - the text of the JPQL statement.
parameters - the positional parameters for place-holders in command text.

getHibernateSession

public org.hibernate.Session getHibernateSession()
Do not use. Convenience method for unit tests.