Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

titleRelease 1.11.4 - new methods
  • SOSHibernateException
    • SOSHibernateLockAcquisitionException
    • SOSHibernateObjectOperationException
  • SOSHibernateSession
    • setAutoCommit
    • isAutoCommit
    • getSingleResultNativeQueryAsMap
    • getSingleResultNativeQueryAsStringMap
    • getSingleResultAsMap
    • getSingleResultAsStringMap
    • getResultListNativeQueryAsMaps
    • getResultListNativeQueryAsStringMaps
    • getResultListAsMaps
    • getResultListAsStringMaps
    • scroll

 

Table of Contents

Class Hierarchy and Deployment

All classes share the package name com.sos.hibernate.classes and are deployed in the archive com.sos-berlin.jobscheduler.hibernate-commons-<version>.jar.

Deployment of the connection package is provided for:

...

Classes and Methods

...

SOSHibernateFactory

Java package : com.sos.hibernate.classes

Creates SOSHibernateSessions SOSHibernateSession.

Wrapper Class for the Hibernate SessionFactory: see https://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/SessionFactory.html

SOSHibernateSession 

Java package : com.sos.hibernate.classes

Runtime Run-time interface between a Java application and Hibernate. 

...

SOSHibernateSQLExecutor

Java package : com.sos.hibernate.classes

Runtime Run-time interface between a Java application and Java Connection.

...

See SOSHibernateSession.getSQLExecutor().

SOSHibernateException

Java package : com.sos.hibernate.exceptions

...

  • SOSHibernateConfigurationException
  • SOSHibernateConnectionException
  • SOSHibernateConvertException
  • SOSHibernateFactoryBuildException
  • SOSHibernateInvalidSessionException
  • SOSHibernateLockAcquisitionException
  • SOSHibernateObjectOperationException
  • SOSHibernateOpenSessionException
  • SOSHibernateQueryException
  • SOSHibernateQueryNonUniqueResultException
  • SOSHibernateSessionException
  • SOSHibernateTransactionException
  • SOSHibernateSQLExecutorException

Configuration

SOSHibernate uses the standard Hibernate configuration to configure Hibernate and allows to set the configuration properties programmatically at runtime.

...

See SOSHibernateFactory.setUseDefaultConfigurationProperties(boolean val).

Public Methods 

SOSHibernateFactory 

Constructors

public SOSHibernateFactory()

Use the mappings and properties specified in an application resource named hibernate.cfg.xml.

           

public SOSHibernateFactory(String hibernateConfigFile)

Use the mappings and properties specified in the given application file.

          

public SOSHibernateFactory(Path hibernateConfigFile)

Use the mappings and properties specified in the given application file.

 

Configuration methods

Configuration methods that can be applied, before Hibernate SessionFactory is created.

public void addClassMapping(ClassList list)

Adds the @Entity annotated classes to the configuration mapping.

Expand
titleSample

import com.sos.hibernate.classes.ClassList;

...

ClassList cl = new ClassList();

cl.add(MyEntity1.class);

cl.add(MyEntity2.class);

cl.addClassIfExist("my.package.MyEntity2");

factory.addClassMapping(cl);

 

public void setIdentifier(String val)  

Sets the factory identifier used by logging.   

 

public void setUseDefaultConfigurationProperties(boolean val)

Sets use defaults configuration properties (default - true).

...

  • hibernate.connection.isolation                   =  String.valueOf(Connection.TRANSACTION_READ_COMMITTED) 
  • hibernate.connection.autocommit                 = false
  • hibernate.jdbc.use_scrollable_resultset = true
  • hibernate.current_session_context_class = jta
  • hibernate.id.new_generator_mappings     = false
  • hibernate.sos.mssql_lock_timeout        = 30000 
  • javax.persistence.validation.mode              = none

 

public void setAutoCommit(boolean commit)     

Sets Hibernate configuration property hibernate.connection.autocommit.   

   

public void setTransactionIsolation(int level)  

Sets Hibernate configuration property hibernate.connection.isolation.     

     

public void setConfigFile(String hibernateConfigFile)   

Sets application file.

Throws: SOSHibernateConfigurationException if file not exist        

 

public void setConfigFile(Path hibernateConfigFile)   

Sets application file.

Throws: SOSHibernateConfigurationException if file not exist

 

public void setConfigurationProperties(Properties properties)

Sets the configuration properties of the current application.

...

Expand
titleSample

...

Properties p = new Properties();

p.put("hibernate.show_sql","true");

p.put("hibernate.connection.autocommit","true");

factory.setConfigurationProperties(p);

...

 

public Enum<SOSHibernateFactory.Dbms> getDbmsBeforeBuild()

Returns: Return the current SOSHibernateFactory.Dbms before SessionFactory is created.

...

Throws: SOSHibernateConfigurationException

 

Create Hibernate SessionFactory

build()

Create a Hibernate SessionFactory using the properties and mappings in this configuration. 

Throws: SOSHibernateFactoryBuildException

 

Methods after Hibernate SessionFactory is created

public SOSHibernateSession openSession()

Open a Session.

Implement a wrapper method for the Hibernate SessionFactory.openSession()

...

Throws: SOSHibernateOpenSessionException

 

public SOSHibernateSession openSession(String identifier)

Open a Session.

Sets the session identifier used by logging.

...

Throws: SOSHibernateOpenSessionException

 

public SOSHibernateSession openStatelessSession()            

Open a new stateless session.

...

Throws: SOSHibernateOpenSessionException

 

public SOSHibernateSession openStatelessSession(String identifier)      

Open a new stateless session.

...

Throws: SOSHibernateOpenSessionException

       

public SOSHibernateSession getCurrentSession()       

Obtains the current session.

...

Throws: SOSHibernateOpenSessionException

   

public SOSHibernateSession getCurrentSession(String identifier)   

Obtains the current session.

...

Throws: SOSHibernateOpenSessionException

                

public String quote(Type type, Object value)      

Quotes the field value dependent of the hibernate type.

...

Expand
titleSamples

...

import org.hibernate.type.*;

...

  • factory.quote(NumericBooleanType,new Boolean(true)));
    • return 1
  • factory.quote(LongType,new Long(100));   
    • return 100
  • factory.quote(StringType,"my_''value");
    • return 'my_''''value'
  • factory.quote(TimestampType,new Date());
    • return
      • Oracle
        • to_date('2017-01-01 12:00:00','yyyy-mm-dd HH24:MI:SS');
      • MS SQL Server
        • '2017-01-01T12:00:00.123'
      • Others
        • '2017-01-01 12:00:00.123'

...

 

public String quoteColumn(String columnName)   

Quotes the column.

Returns: quoted column name

Expand
titleSamples

...

factory.quoteColumn("MY_COLUMN");

e.g. return

  • MS SQL Server
    • [MY_COLUMN]
  • MySQL
    • `MY_COLUMN`

...

 

public Dialect getDialect()        

Returns: Hibernate Dialect. See https://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/dialect/Dialect.html   

 

public SessionFactory getSessionFactory()         

Returns: Hibernate SessionFactory. See https://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/SessionFactory.html

 

public Enum<SOSHibernateFactory.Dbms> getDbms()    

Returns: Return the current SOSHibernateFactory.Dbms.

...

UNKNOWN, DB2, FBSQL, MSSQL, MYSQL, ORACLE, PGSQL, SYBASE       

 

public String getSequenceLastValString(String sequenceName)      

Returns the most recent statement of a sequence generator.

...

  • MS SQL Server
    • SELECT @@IDENTITY
  • MySQL
    • SELECT LAST_INSERT_ID();
  • Oracle
    • SELECT <sequenceName>.currval FROM DUAL;
  • PostreSQL
    • SELECT currval('<sequenceName>');
  • DB2
    • SELECT IDENTITY_VAL_LOCAL() AS INSERT_ID FROM SYSIBM.SYSDUMMY1
  • Sybase
    • SELECT @@IDENTITY

 

public void close()

Destroy this SessionFactory and release all resources (caches, connection pools, etc). 

...

See https://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/SessionFactory.html#close--

 

Others

public boolean getAutoCommit()     

Returns: Hibernate configuration property hibernate.connection.autocommit.

Throws: SOSHibernateConfigurationException - if not configured

 

public int getTransactionIsolation()   

Returns: Hibernate configuration property hibernate.connection.isolation.

Throws: SOSHibernateConfigurationException - if not configured      

 

public static String getTransactionIsolationName(int isolationLevel)    

Returns: Transaction isolation name.

...

Throws: SOSHibernateConfigurationException - if invalid isolationLevel    

     

public Optional<Path> getConfigFile()       

Returns: application file.    

 

public Configuration getConfiguration()   

Returns: Hibernate Configuration. See  https://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/cfg/Configuration.html    

    

public Properties getConfigurationProperties()

Returns: configuration properties defined by the current application. 


public ClassList getClassMapping()

Returns: mapping entities defined by the current application. 


public boolean isUseDefaultConfigurationProperties()

Returns: default configuration properties using.

 

public Properties getDefaultConfigurationProperties()   

Returns: default configuration properties.

See SOSHibernateFactory.setUseDefaultConfigurationProperties

 

public String getIdentifier()         

Returns: gets the factory identifier.  

 

public Optional<Integer> getJdbcFetchSize()

Returns: Hibernate configuration property hibernate.jdbc.fetch_size.

 

SOSHibernateSession

Constructors

No public constructors available.

...

  • SOSHibernateFactory.openSession
  • SOSHibernateFactory.openStatelessSession
  • SOSHibernateFactory.getCurrentSession

Set

public void setAutoCommit(boolean val)

Sets the session autocommit.

Default - SOSHibernateFactory.getAutoCommit()

 

public void setIdentifier(String val)

Sets the session identifier used by logging.   

 

public void setCacheMode(CacheMode cacheMode) 

Implement a wrapper method for the Hibernate Session.setCacheMode(CacheMode cashMode).                                                        

...

Note: works only with Hibernate Session interface, not with StatelessSession interface.  

      

public void setHibernateFlushMode(FlushMode flushMode)

Represents a flushing strategy.                                                      

...

Note: works only with Hibernate Session interface, not with StatelessSession interface.

 

Get

public boolean isAutoCommit()  

Returns: session autocommit mode.

 

public boolean isStatelessSession()  

Returns: Check if the SOSHibernateSession was created by SessionFactory.openStatelessSession().   

 

public boolean isGetCurrentSession()   

Returns: Check if the SOSHibernateSession was created by SessionFactory.getCurrentSession().     

  

public boolean isOpen() 

Implement a wrapper method for the Hibernate Session/StatelessSession isOpen.

Returns: Check if the session is still open.

 

public boolean isConnected() 

Implement a wrapper method for the Hibernate Session/StatelessSession isConnected.

Returns: Check if the session is currently connected.   

 

public SOSHibernateFactory getFactory()        

Returns: SOSHibernateFactory.

 

public SOSHibernateSQLExecutor getSQLExecutor()        

Returns: SOSHibernateSQLExecutor.

 

public String getIdentifier()     

Returns: session identifier. 

 

public FlushMode getHibernateFlushMode()  

Returns: Hibernate FlushMode. See https://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/FlushMode.html

Note: works only with Hibernate Session interface, not with StatelessSession interface.

 

public CacheMode getCacheMode()        

Returns: Hibernate CashMode. See https://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/FlushMode.html    

Note: works only with Hibernate Session interface, not with StatelessSession interface.  

 

public Object getCurrentSession()   

Returns:current Session or StatelessSession object.

 

public Connection getConnection()      

Returns: java.sql.Connection.

 

Session

public void close()     

Close the Hibernate Session / StatelessSession.

 

public void clearSession()

Completely clear the session.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateSessionException

Transaction

public void beginTransaction() 

Implement a wrapper method for the Hibernate Session / StatelessSession beginTransaction().

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateTransactionException

       

public void commit() 

Implement a wrapper method for the Hibernate Session / StatelessSession commit().

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateTransactionException

       

public void rollback() 

Implement a wrapper method for the Hibernate Session / StatelessSession rollback().

ThrowsSOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateTransactionException     

 

public Transaction getTransaction() 

Implement a wrapper method for the Hibernate Session / StatelessSession getTransaction().

...

ThrowsSOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateTransactionException  

 

Hibernate object/entity

public void save(Object item) 

Persist the given transient instance, first assigning a generated identifier.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateObjectOperationException

 

public void update(Object item) 

Update the persistent instance with the identifier of the given detached instance.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateObjectOperationException

 

public void saveOrUpdate(Object item) 

Persist or update the persistent instance with the identifier of the given detached instance.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateObjectOperationException

 

public void delete(Object item) 

Remove a persistent instance from the datastore.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateObjectOperationException

    

public void refresh(Object object) 

Re-read the state of the given instance from the underlying database.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateObjectOperationException

   

public void refresh(String entityName, Object object) 

Re-read the state of the given instance from the underlying database.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateObjectOperationException

 

public <T> T get(Class<?> entityClass, Serializable id) 

Returns: persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateObjectOperationException

       

Native Queries

Create

public <T> NativeQuery<T> createNativeQuery(String sql)         

Create a NativeQuery instance for the given native (SQL) query string.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

 

public <T> NativeQuery<T> createNativeQuery(String sql, Class<T> entityClass)    

Create a NativeQuery instance for the given native (SQL) query string using implicit mapping to the specified Java type.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

 

Execute


public void executeUpdateNativeQuery(String sql)      

The method executes statements as UPDATE, INSERT, DELETE..

...

Throws: SOSHibernateInvalidSessionException,SOSHibernateLockAcquisitionException, SOSHibernateQueryException

 

public void executeUpdate(Query<?> query)      

The method executes statements as UPDATE, INSERT, DELETE..

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

 

Select  

public String getSingleValueNativeQueryAsString(String sql)    

Creates and get the result of the Hibernate NativeQuery.

...

               Note: difference to Query.getSingleResult - not throw NoResultException.

 

public <T> T getSingleValueNativeQuery(String sql)    

Creates and get the result of the Hibernate NativeQuery.

...

               Note: difference to Query.getSingleResult - not throw NoResultException. 

                  

 

public <T> T getSingleValue(NativeQuery query)    

 Get the result of the Hibernate NativeQuery.

...

               Note: difference to Query.getSingleResult - not throw NoResultException. 

 

public String getSingleValueAsString(NativeQuery query)    

 Get the result of the Hibernate NativeQuery.

...

                Note: difference to Query.getSingleResult - not throw NoResultException.


public <T> T getSingleResultNativeQuery(String sql)     

 Creates a NativeQuery from sql query string and execute <T> T getSingleResult(NativeQuery<T> nativeQuery)

...

 Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryNonUniqueResultException, SOSHibernateQueryException

 

 

public <T> Map<String, Object> getSingleResultNativeQueryAsMap(String sql)     

 Creates a NativeQuery from sql query string and execute <T> Map<String, Object> getSingleResultAsMap(NativeQuery<T> nativeQuery)

...

 Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryNonUniqueResultException, SOSHibernateQueryException


public <T> Map<String, String> getSingleResultNativeQueryAsStringMap(String sql)     

Creates a NativeQuery from sql query string and execute <T> Map<String, String> getSingleResultAsStringMap(NativeQuery<T> nativeQuery, String dateTimeFormat)

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryNonUniqueResultException, SOSHibernateQueryException

   

public <T> Map<String, String> getSingleResultNativeQueryAsStringMap(String sql, String dateTimeFormat)

Creates a NativeQuery from sql query string and execute <T> Map<String, String> getSingleResultAsStringMap(NativeQuery<T> nativeQuery, String dateTimeFormat)

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryNonUniqueResultException, SOSHibernateQueryException


 

public <T> T getSingleResult(NativeQuery<T> nativeQuery)    

 The method reads one record from a query.

...

               Note: difference to Query.getSingleResult - not throw NoResultException.    

public <T> Map<String, Object> getSingleResultAsMap(NativeQuery<T> nativeQuery)    

The method reads one record from a query.

...

               Note: difference to Query.getSingleResult - not throw NoResultException.          


public <T> Map<String, String> getSingleResultAsStringMap(NativeQuery<T> nativeQuery, String dateTimeFormat)   

The method reads one record from a query and format the Date fileds. 

...

              Note: difference to Query.getSingleResult - not throw NoResultException.                   


 

public <T> List<T> getResultListNativeQuery(String sql)   

 Creates a NativeQuery from sql query string and execute <T> List<T> getResultList(Query<T> query)

...

 Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException


public <T> List<Map<String, Object>> getResultListNativeQueryAsMaps(String sql)   

Creates a NativeQuery from sql query string and execute <T> List<Map<String, Object>> getResultListAsMaps(NativeQuery<T> nativeQuery)

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException


 

public <T> List<Map<String, String>> getResultListNativeQueryAsStringMaps(String sql)     

 Creates a NativeQuery from sql query string and execute <T> List<Map<String, String>> getResultListAsStringMaps(NativeQuery<T> nativeQuery, String dateTimeFormat)

...

 Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException


public <T> List<Map<String, String>> getResultListNativeQueryAsStringMaps(String sql, String dateTimeFormat)     

Creates a NativeQuery from sql query string and execute <T> List<Map<String, String>> getResultListAsStringMaps(NativeQuery<T> nativeQuery, String dateTimeFormat)

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException


public <T> List<T> getResultList(NativeQuery<T> nativeQuery)      

The method reads all records from a query. 

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

                   

 

public <T> List<Map<String, Object>> getResultListAsMaps(NativeQuery<T> nativeQuery)      

 The method reads all records from a query. 

...

 Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException


public <T> List<Map<String, String>> getResultListAsStringMaps(NativeQuery<T> query)      

The method reads all records from a query. 

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

     

public <T> List<Map<String, String>> getResultListAsStringMaps(NativeQuery<T> query, String dateTimeFormat) 

The method reads all records from a query and format the Date fileds.  

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

 

public <T> ScrollableResults scroll(NativeQuery<T> nativeQuery)

The method executes the scroll method with the ScrollMode.FORWARD_ONLY

See ScrollableResults scroll(Query<T> nativeQuery, ScrollMode scrollMode);

 

public <T> ScrollableResults scroll(Query<T> nativeQuery, ScrollMode scrollMode)

The method executes a sql query statements and preserves the result set.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

 

public String getLastSequenceValue(String sequenceName)   

Returns: the most recent value of a sequence generator.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryNonUniqueResultException, SOSHibernateQueryException

      

SOSHibernateSQLExecutor

Called by session.getSQLExecutor(). 

public void setDefaults()   

The following default settings are applied: 

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException

public List<String> getStatements(Path file)       

Returns: List of the individual SQL query statements from multiple statements that are specified in the file.  

Throws: SOSHibernateSQLCommandExtractorException, SOSHibernateSQLExecutorException

 

public List<String> getStatements(String content)    

Returns: List of the individual sql query statements from multiple statements that are specified in the method argument. This method implements a parser that isolates statements and respects DDL statements (create procedure etc.) and DML statements.      

Throws: SOSHibernateSQLCommandExtractorException

 

public void executeStatements(Path file)     

Execute individual SQL query statements from multiple statements that are specified in the file.

ThrowsSOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLCommandExtractorException, SOSHibernateSQLExecutorException     

 

public void executeStatements(String content)  

Execute individual SQL query statements from multiple statements that are specified in the method argument. 

ThrowsSOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLCommandExtractorException, SOSHibernateSQLExecutorException

 

public boolean execute(String... sqls)      

The method executes one or more statements, e.g. calls to stored procedures.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException

     

 

public void executeUpdate(String... sqls)      

The method executes DML statements as UPDATE, INSERT, DELETE..

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException

 

public void executeQuery(String sql)       

The method executes a sql query statement without preserves the result set.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException

 

 

public int[] executeBatch(String... sqls)  

The method executes one or more statements as batch.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException

      

public int executeUpdateCallableStatement(String sql)  

Implement a wrapper method for the java.sql.CallableStatement.executeUpdate().

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException

 

public ResultSet getResultSet(String sql)

The method executes a sql query statements and preserves the result set.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException

 

public Map<String, String> next(ResultSet rs)

The method reads the next record from the result set returned by a query.

...

Throws: SOSHibernateSQLExecutorException

 

public Map<String, String> nextAsStringMap(ResultSet rs)

The method reads the next record from the result set returned by a query.

...

Throws: SOSHibernateSQLExecutorException

 

public void close(ResultSet rs)

The method closes the result set and statement objects.

See Samples.

 

BLOB/CLOB
public byte[] getBlob(String sql)   

This method retrieves the content of a BLOB database field.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException

             

public long getBlob(String sql, Path path)       

This method saves the content of a BLOB database field in a new file.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException

 

public String getClob(String sql)      

This method retrieves the content of a CLOB database field.  

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException


public long getClob(String sql, Path path)

This method retrieves the content of a CLOB database field to a file.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException

 

public int updateBlob(Path path, String tableName, String columnName, String condition)  

This method saves the content of a file in a BLOB database field.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException


public int updateBlob(byte[] data, String tableName, String columnName, String condition)    

This method saves the content of a byte array in a BLOB database field. 

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException

           

public void updateBlob(InputStream inputStream, int dataLength, String tableName, String columnName, String condition)     

This method saves the InputStream in a BLOB database field. 

ThrowsSOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException     

            

public int updateClob(Path path, String tableName, String columnName, String condition)        

This method saves the content of a file in a CLOB database field. 

...

ThrowsSOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException  


public int updateClob(String data, String tableName, String columnName, String condition)            

This method saves the string data in a CLOB database field.  

...

ThrowsSOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException  

   

public void updateClob(Reader reader, int dataLength, String tableName, String columnName, String condition)    

This method saves the Reader in a CLOB database field.   

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException

 

HQL/JPQL Queries

Wrapper methods using Hibernate Query interface.

Create 

public <T> Query<T> createQuery(String hql)  

Create a Query instance for the given HQL/JPQL query string.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

 

Execute

 

public void executeUpdate(String hql)      

The method executes statements as UPDATE, INSERT, DELETE..

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

 

public void executeUpdate(Query<?> query)      

The method executes statements as UPDATE, INSERT, DELETE..

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

 

Select

public <T> T getSingleValue(String hql)  

Creates a Query from HQL/JPQL query string and execute <T> T getSingleValue(Query<T> query).

Returns:See <T> T getSingleValue(Query<T> query).
Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryNonUniqueResultException, SOSHibernateQueryException

 

public String getSingleValueAsString(String hql)  

 Creates a Query from HQL/JPQL query string and execute <T> T getSingleValue(Query<T> query).

 Returns: value as String or null in the event of an empty result set.
Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryNonUniqueResultException, SOSHibernateQueryException


public <T> T getSingleValue(Query<T> query)     

The method reads a value of the first record from the result set of a Query.

...

               Note: difference to Query.getSingleResult - not throw NoResultException.

                  

 

public <T> String getSingleValueAsString(Query<T> query)     

 The method reads a value of the first record from the result set of a Query.

...

                Note: difference to Query.getSingleResult - not throw NoResultException.


public <T> T getSingleResult(String hql) 

Creates a Query from HQL/JPQL query string and execute <T> T getSingleResult(Query<T> query).

...

ThrowsSOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryNonUniqueResultException, SOSHibernateQueryException

         

public <T> T getSingleResult(Query<T> query) 

The method reads one record from a query.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryNonUniqueResultException, SOSHibernateQueryException
               Note: difference to Query.getSingleResult - not throw NoResultException.

 

public List<T> T getResultList(String hql) 

Creates a Query from HQL/JPQL query string and execute <T> T getResultList(Query<T> query).

...

ThrowsSOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException
 

public List<T> T getResultList(Query<T> query) 

The method reads all records from a query.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException


public <T> ScrollableResults scroll(Query<T> query)

The method executes the scroll method with the ScrollMode.FORWARD_ONLY

See ScrollableResults scroll(Query<T> query, ScrollMode scrollMode);

 

public <T> ScrollableResults scroll(Query<T> query, ScrollMode scrollMode)

The method executes a sql query statements and preserves the result set.

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, , SOSHibernateQueryException


SOSHibernateException

Additional public methods:

public SQLException getSQLException

Returns: java.sql.SQLException or null

 

public String getStatement()

Returns: sql/hql statement, [n/a] for not available or null.

 

public String toString()

Returns: provides additionally the sql/hql statement if possible.

History of SOSHibernate with JobScheduler Releases

Info
titleRelease 1.

...

11.4 - new methods
  • SOSHibernateException
    • SOSHibernateLockAcquisitionException
    • SOSHibernateObjectOperationException
  • SOSHibernateSession
    • setAutoCommit
    • isAutoCommit
    • getSingleResultNativeQueryAsMap
    • getSingleResultNativeQueryAsStringMap
    • getSingleResultAsMap
    • getSingleResultAsStringMap
    • getResultListNativeQueryAsMaps
    • getResultListNativeQueryAsStringMaps
    • getResultListAsMaps
    • getResultListAsStringMaps
    • scroll