Versions Compared

Key

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

Table of Contents

Classes and

...

Exceptions

SOSHibernateFactory

Java package : com.sos.hibernate.classes

...

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

Configuration Items

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

...

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

public void addClassMapping(Class<?> c)

Adds the @Entity annotated single class to the configuration mapping.

public void addClassMapping(ClassList list)

Adds the @Entity annotated classes to the configuration mapping.

...

Create Hibernate SessionFactory

public void build()

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

...

Throws: SOSHibernateConfigurationException - if invalid isolationLevel       

public static String toString(Object dbItem)    

Returns: dumping a java object's public properties.

Note: starting with JobScheduler 1.11.5


      

public Optional<Path> getConfigFile()       

...

Default - SOSHibernateFactory.getAutoCommit()

Note: starting with JobScheduler 1.11.4

 

public void setIdentifier(String val)

...

Returns: session autocommit mode.

Note: starting with JobScheduler 1.11.4

 

public boolean isStatelessSession()  

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

 

Execute


public

...

int executeUpdateNativeQuery(String sql)      

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

Implement a wrapper method for the Hibernate executeUpdate.

Returns: The number of entities updated or deleted.

Throws: SOSHibernateInvalidSessionException,SOSHibernateLockAcquisitionException, SOSHibernateQueryException

 

public

...

int executeUpdate(Query<?> query)      

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

...

To execute the native statements Query param must be a NativeQuery.

Returns: The number of entities updated or deleted.

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

 

Select  

public <T> String getSingleValueNativeQueryAsString(String sql)    

Creates and get the result of the Hibernate NativeQuery.

...

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

                  

 

public <T> T getSingleValue(

...

Query<T> query)    

 Get the result of the Hibernate Query or NativeQuery.

 The method reads a scalar value – usually a field – of the first record from the result set of a Query or NativeQuery.

 Returns: T Object or null in the event of an empty result set. 

...

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

 

public <T> String getSingleValueAsString(

...

Query<T> query)    

 Get the result of the Hibernate Query or NativeQuery.

 The method reads a scalar value – usually a field – of the first record from the result set of a Query or NativeQuery.

 Returns: String or null in the event of an empty result set. 

...

public <T> T getSingleResultNativeQuery(String sql)     

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

 See <T> T getSingleResult(NativeQuery<T> nativeQuery);    

 Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryNonUniqueResultException, SOSHibernateQueryException

...

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

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

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

 ThrowsThrows: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryNonUniqueResultException, SOSHibernateQueryException

Note: starting with JobScheduler 1.11.4


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)

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

ThrowsThrows: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryNonUniqueResultException, SOSHibernateQueryException

Note: starting with JobScheduler 1.11.4

   

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)

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

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryNonUniqueResultException, SOSHibernateQueryException

Note: starting with JobScheduler 1.11.4

 

public <T> T getSingleResult(

...

Query<T> query)    

 The method reads one record from a query .

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

(Query or NativeQuery).

 Throws: SOSHibernateInvalidSessionException, SOSHibernateQueryNonUniqueResultException, SOSHibernateQueryException

...

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

Note: starting with JobScheduler 1.11.4


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

...

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

Note: starting with JobScheduler 1.11.4


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

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

 See <T> List<T> getResultList(Query<T> query);      Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

...

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

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

 Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

Note: starting with JobScheduler 1.11.4

 

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)

 See <T> List<Map<String, String>> getResultListAsStringMaps(NativeQuery<T> nativeQuery, String dateTimeFormat);

 Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryExceptionSOSHibernateQueryException

Note: starting with JobScheduler 1.11.4


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)

See <T> List<Map<String, String>> getResultListAsStringMaps(NativeQuery<T> nativeQuery, String dateTimeFormat);

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

Note: starting with JobScheduler 1.11.4


public <T> List<T> getResultList(

...

Query<T> query)      

The method reads all records from a query (Query or NativeQuery)

See <T> List<T> getResultList(Query<T> query);

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException                   

 

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

...

 Returns: A List of the Maps consisting of column names and values – null for empty result sets.

  •  Map key     - column name in lower case.
  • Map value  - object (null value as NULL)

 Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

Note: starting with JobScheduler 1.11.4


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

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

Note: starting with JobScheduler 1.11.4

     

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

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

Note: starting with JobScheduler 1.11.4

 

public <T> ScrollableResults scroll(

...

Query<T> query)

The method executes the scroll method with the ScrollMode.FORWARD_ONLY

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

Note: starting with JobScheduler 1.11.4

 

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

Note: starting with JobScheduler 1.11.4

 

public String getLastSequenceValue(String sequenceName)   

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException

     

 

public

...

int executeUpdate(String... sqls)      

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

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

Returns: The number of entities updated or deleted.

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateConnectionException, SOSHibernateSQLExecutorException

 

public Map<String,

...

Object> next(ResultSet rs)

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

...

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

 

Execute

 

public

...

int executeUpdate(String hql)      

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

Creates a Query from HQL/JPQL query string and execute int executeUpdate(Query<?> query).

Returns: See int executeUpdate(Query<?> query)Implement a wrapper method for the Hibernate executeUpdate.

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

 

public

...

int executeUpdate(Query<?> query)      

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

Implement a wrapper method for the Hibernate executeUpdate.

Returns: The number of entities updated or deleted.

Throws: SOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException

...

 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.

...

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 <T> List<T>

...

getResultList(String hql) 

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

...

ThrowsSOSHibernateInvalidSessionException, SOSHibernateLockAcquisitionException, SOSHibernateQueryException
 

public <T> List<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);

Note: starting with JobScheduler 1.11.4

 

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

Note: starting with JobScheduler 1.11.4

SOSHibernateException

Additional public methods:

...

History of SOSHibernate with JobScheduler Releases

Info
titleRelease 1.11.1 - new methods
  • SOSHibernateFactory
    • addClassMapping(Class<?> c)

Info
titleRelease 1.11.4 - new methods
  • SOSHibernateException
    • SOSHibernateLockAcquisitionException
    • SOSHibernateObjectOperationException
  • SOSHibernateSession
    • setAutoCommit
    • isAutoCommit
    • getSingleResultNativeQueryAsMap
    • getSingleResultNativeQueryAsStringMap
    • getSingleResultAsMap
    • getSingleResultAsStringMap
    • getResultListNativeQueryAsMaps
    • getResultListNativeQueryAsStringMaps
    • getResultListAsMaps
    • getResultListAsStringMaps
    • scroll
Info
titleRelease 1.11.5 - new methods
  • SOSHibernateException
    • SOSHibernateObjectOperationStaleStateException
  • SOSHibernateFactory
    • toString(Object dbItem)