org.sqlproc.engine.hibernate
Class HibernateQuery

java.lang.Object
  extended by org.sqlproc.engine.hibernate.HibernateQuery
All Implemented Interfaces:
SqlQuery

public class HibernateQuery
extends Object
implements SqlQuery

The Hibernate stack implementation of the SQL Engine query contract. In fact it's an adapter the internal Hibernate stuff.

For more info please see the Tutorials.

Author:
Vladimir Hudec

Nested Class Summary
(package private) static class HibernateQuery.BatchResultHolder
           
 
Field Summary
(package private)  List<String> identities
          The collection of all (auto-generated) identities.
(package private)  Map<String,IdentitySetter> identitySetters
          The collection of all identities setters.
(package private)  Map<String,Object> identityTypes
          The collection of all identities types.
(package private)  boolean logError
          The failed SQL command should be logged.
(package private)  org.slf4j.Logger logger
          The internal slf4j logger.
(package private)  org.hibernate.SQLQuery query
          The Hibernate SQLQuery instance.
(package private)  org.hibernate.Session session
          The Hibernate Session instance.
 
Constructor Summary
HibernateQuery(org.hibernate.Session session, org.hibernate.SQLQuery query)
          Creates a new instance of this adapter.
 
Method Summary
 SqlQuery addScalar(String columnAlias)
          
 SqlQuery addScalar(String columnAlias, Object type)
          
 Object callFunction()
          
 List callList()
          
 Object callUnique()
          
 int callUpdate()
          
private  void doIdentitySelect(String identityName)
          Runs the select to obtain the value of auto-generated identity.
 int[] executeBatch(String[] statements)
          
 Object getQuery()
          
private  boolean isSetJDBCIdentity()
           
 List list()
          
protected  SqlProcessorException newSqlProcessorException(org.hibernate.HibernateException ex, String query)
           
 SqlQuery setFirstResult(int firstResult)
          
 void setLogError(boolean logError)
          Sets an indicator the failed SQL command should be logged
 SqlQuery setMaxResults(int maxResults)
          
 SqlQuery setOrdered(boolean ordered)
          
 SqlQuery setParameter(String name, Object val)
          
 SqlQuery setParameter(String name, Object val, Object type)
          
 SqlQuery setParameterList(String name, Object[] vals)
          
 SqlQuery setParameterList(String name, Object[] vals, Object type)
          
 SqlQuery setTimeout(int timeout)
          
 Object unique()
          
 int update()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

final org.slf4j.Logger logger
The internal slf4j logger.


session

org.hibernate.Session session
The Hibernate Session instance.


query

org.hibernate.SQLQuery query
The Hibernate SQLQuery instance.


identities

List<String> identities
The collection of all (auto-generated) identities.


identitySetters

Map<String,IdentitySetter> identitySetters
The collection of all identities setters.


identityTypes

Map<String,Object> identityTypes
The collection of all identities types.


logError

boolean logError
The failed SQL command should be logged.

Constructor Detail

HibernateQuery

public HibernateQuery(org.hibernate.Session session,
                      org.hibernate.SQLQuery query)
Creates a new instance of this adapter.

Parameters:
session - the Hibernate Session instance
query - the Hibernate SQLQuery instance
Method Detail

getQuery

public Object getQuery()

Specified by:
getQuery in interface SqlQuery

setTimeout

public SqlQuery setTimeout(int timeout)

Specified by:
setTimeout in interface SqlQuery

setFirstResult

public SqlQuery setFirstResult(int firstResult)

Specified by:
setFirstResult in interface SqlQuery

setMaxResults

public SqlQuery setMaxResults(int maxResults)

Specified by:
setMaxResults in interface SqlQuery

setOrdered

public SqlQuery setOrdered(boolean ordered)

Specified by:
setOrdered in interface SqlQuery

list

public List list()
          throws SqlProcessorException

Specified by:
list in interface SqlQuery
Throws:
SqlProcessorException

unique

public Object unique()
              throws SqlProcessorException

Specified by:
unique in interface SqlQuery
Throws:
SqlProcessorException

update

public int update()
           throws SqlProcessorException

Specified by:
update in interface SqlQuery
Throws:
SqlProcessorException

isSetJDBCIdentity

private boolean isSetJDBCIdentity()

doIdentitySelect

private void doIdentitySelect(String identityName)
Runs the select to obtain the value of auto-generated identity.

Parameters:
identityName - the identity name from the META SQL statement

addScalar

public SqlQuery addScalar(String columnAlias)

Specified by:
addScalar in interface SqlQuery

addScalar

public SqlQuery addScalar(String columnAlias,
                          Object type)

Specified by:
addScalar in interface SqlQuery

setParameter

public SqlQuery setParameter(String name,
                             Object val)
                      throws SqlProcessorException

Specified by:
setParameter in interface SqlQuery
Throws:
SqlProcessorException

setParameter

public SqlQuery setParameter(String name,
                             Object val,
                             Object type)
                      throws SqlProcessorException

Specified by:
setParameter in interface SqlQuery
Throws:
SqlProcessorException

setParameterList

public SqlQuery setParameterList(String name,
                                 Object[] vals)
                          throws SqlProcessorException

Specified by:
setParameterList in interface SqlQuery
Throws:
SqlProcessorException

setParameterList

public SqlQuery setParameterList(String name,
                                 Object[] vals,
                                 Object type)
                          throws SqlProcessorException

Specified by:
setParameterList in interface SqlQuery
Throws:
SqlProcessorException

callList

public List callList()
              throws SqlProcessorException

Specified by:
callList in interface SqlQuery
Throws:
SqlProcessorException

callUnique

public Object callUnique()
                  throws SqlProcessorException

Specified by:
callUnique in interface SqlQuery
Throws:
SqlProcessorException

callUpdate

public int callUpdate()
               throws SqlProcessorException

Specified by:
callUpdate in interface SqlQuery
Throws:
SqlProcessorException

callFunction

public Object callFunction()
                    throws SqlProcessorException

Specified by:
callFunction in interface SqlQuery
Throws:
SqlProcessorException

executeBatch

public int[] executeBatch(String[] statements)
                   throws SqlProcessorException

Specified by:
executeBatch in interface SqlQuery
Throws:
SqlProcessorException

newSqlProcessorException

protected SqlProcessorException newSqlProcessorException(org.hibernate.HibernateException ex,
                                                         String query)

setLogError

public void setLogError(boolean logError)
Sets an indicator the failed SQL command should be logged

Specified by:
setLogError in interface SqlQuery
Parameters:
logError - an indicator the failed SQL command should be logged


Copyright © 2013. All Rights Reserved.