Class HibernatePersistentObjectDAO<T extends PersistentObject>

    • Method Detail

      • setSessionFactory

        public void setSessionFactory​(org.hibernate.SessionFactory sessionFactory)
      • findByWhere

        public List<T> findByWhere​(String where,
                                   Object[] values,
                                   String order,
                                   Integer max)
                            throws PersistenceException
        Description copied from interface: PersistentObjectDAO
        Finds all entities by the given expression. Use _entity alias to reference attributes in the where expression.
        Specified by:
        findByWhere in interface PersistentObjectDAO<T extends PersistentObject>
        Parameters:
        where - The where clause expression (for positional parameters, please use JPA-style: ?1, ?2 ...)
        values - Parameters used in the where expression
        order - The order clause expression
        max - Maximum results number (optional)
        Returns:
        The list of marching entities
        Throws:
        PersistenceException - raised in case of errors in the database
      • findIdsByWhere

        public List<Long> findIdsByWhere​(String where,
                                         Object[] values,
                                         String order,
                                         Integer max)
                                  throws PersistenceException
        Description copied from interface: PersistentObjectDAO
        Finds all entities ids by the given expression. Use _entity alias to reference attributes in the where expression.
        Specified by:
        findIdsByWhere in interface PersistentObjectDAO<T extends PersistentObject>
        Parameters:
        where - The where clause expression (for positional parameters, please use JPA-style: ?1, ?2 ...)
        values - Parameters used in the where expression
        order - The order clause expression
        max - Maximum results number (optional)
        Returns:
        The list of marching entities ids
        Throws:
        PersistenceException - raised in case of errors in the database
      • query

        public List query​(String sql,
                          Object[] args,
                          org.springframework.jdbc.core.RowMapper rowMapper,
                          Integer maxRows)
                   throws PersistenceException
        Description copied from interface: PersistentObjectDAO
        Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, mapping each row to a Java object via a RowMapper.
        Specified by:
        query in interface PersistentObjectDAO<T extends PersistentObject>
        Parameters:
        sql - SQL query to execute
        args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type); may also contain SqlParameterValue objects which indicate not only the argument value but also the SQL type and optionally the scale
        rowMapper - object that will map one object per row
        maxRows - the new max rows limit; null means there is no limit
        Returns:
        the result List, containing mapped objects
        Throws:
        PersistenceException - raised in case of errors in the database
      • queryForList

        public List queryForList​(String sql,
                                 Object[] args,
                                 Class elementType,
                                 Integer maxRows)
                          throws PersistenceException
        Description copied from interface: PersistentObjectDAO
        Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result list. The results will be mapped to a List (one entry for each row) of result objects, each of them matching the specified element type.
        Specified by:
        queryForList in interface PersistentObjectDAO<T extends PersistentObject>
        Parameters:
        sql - SQL query to execute
        args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type); may also contain SqlParameterValue objects which indicate not only the argument value but also the SQL type and optionally the scale
        elementType - the required type of element in the result list (for example, Integer.class)
        maxRows - maximum number of returned records
        Returns:
        a List of objects that match the specified element type
        Throws:
        PersistenceException - raised in case of errors in the database
      • queryForRowSet

        public org.springframework.jdbc.support.rowset.SqlRowSet queryForRowSet​(String sql,
                                                                                Object[] args,
                                                                                Integer maxRows)
                                                                         throws PersistenceException
        Description copied from interface: PersistentObjectDAO
        Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, returns a navigable RowSet
        Specified by:
        queryForRowSet in interface PersistentObjectDAO<T extends PersistentObject>
        Parameters:
        sql - SQL query to execute
        args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type); may also contain SqlParameterValue objects which indicate not only the argument value but also the SQL type and optionally the scale
        maxRows - the new max rows limit; null means there is no limit
        Returns:
        the result row set
        Throws:
        PersistenceException - raised in case of errors in the database
      • queryForList

        public List queryForList​(String sql,
                                 Class elementType)
                          throws PersistenceException
        Description copied from interface: PersistentObjectDAO
        Execute a query for a result list, given static SQL. Uses a JDBC Statement, not a PreparedStatement. If you want to execute a static query with a PreparedStatement, use the overloaded queryForList method with null as argument array. The results will be mapped to a List (one entry for each row) of result objects, each of them matching the specified element type.
        Specified by:
        queryForList in interface PersistentObjectDAO<T extends PersistentObject>
        Parameters:
        sql - SQL query to execute
        elementType - the required type of element in the result list (for example, Integer.class)
        Returns:
        a List of objects that match the specified element type
        Throws:
        PersistenceException - raised in case of errors in the database
      • queryForInt

        public int queryForInt​(String sql)
                        throws PersistenceException
        Description copied from interface: PersistentObjectDAO
        Execute a query that results in an int value, given static SQL. Uses a JDBC Statement, not a PreparedStatement. If you want to execute a static query with a PreparedStatement, use the overloaded queryForInt method with null as argument array. This method is useful for running static SQL with a known outcome. The query is expected to be a single row/single column query that results in an int value.
        Specified by:
        queryForInt in interface PersistentObjectDAO<T extends PersistentObject>
        Parameters:
        sql - SQL query to execute
        Returns:
        the int value, or 0 in case of SQL NULL
        Throws:
        PersistenceException - raised in case of errors in the database
      • queryForLong

        public long queryForLong​(String sql)
                          throws PersistenceException
        Description copied from interface: PersistentObjectDAO
        Execute a query that results in an long value, given static SQL. Uses a JDBC Statement, not a PreparedStatement. If you want to execute a static query with a PreparedStatement, use the overloaded queryForInt method with null as argument array. This method is useful for running static SQL with a known outcome. The query is expected to be a single row/single column query that results in a long value.
        Specified by:
        queryForLong in interface PersistentObjectDAO<T extends PersistentObject>
        Parameters:
        sql - SQL query to execute
        Returns:
        the long value, or 0 in case of SQL NULL
        Throws:
        PersistenceException - raised in case of errors in the database
      • queryForString

        public String queryForString​(String sql)
                              throws PersistenceException
        Description copied from interface: PersistentObjectDAO
        Execute a query that results in an string value, given static SQL. Uses a JDBC Statement, not a PreparedStatement. If you want to execute a static query with a PreparedStatement, use the overloaded queryForInt method with null as argument array. This method is useful for running static SQL with a known outcome. The query is expected to be a single row/single column query that results in a string value.
        Specified by:
        queryForString in interface PersistentObjectDAO<T extends PersistentObject>
        Parameters:
        sql - SQL query to execute
        Returns:
        the string value
        Throws:
        PersistenceException - raised in case of errors in the database
      • queryForObject

        public Object queryForObject​(String sql,
                                     Class type)
                              throws PersistenceException
        Description copied from interface: PersistentObjectDAO
        Execute a query that results in a Object value, given static SQL. Uses a JDBC Statement, not a PreparedStatement. If you want to execute a static query with a PreparedStatement. This method is useful for running static SQL with a known outcome. The query is expected to be a single row/single column query that results in a object value.
        Specified by:
        queryForObject in interface PersistentObjectDAO<T extends PersistentObject>
        Parameters:
        sql - SQL query to execute
        type - The type of the returned value
        Returns:
        the object value
        Throws:
        PersistenceException - raised in case of errors in the database
      • jdbcUpdate

        public int jdbcUpdate​(String statement,
                              Object... args)
                       throws PersistenceException
        Description copied from interface: PersistentObjectDAO
        Issue a single SQL update operation (such as an insert, update or delete statement) via a prepared statement, binding the given arguments
        Specified by:
        jdbcUpdate in interface PersistentObjectDAO<T extends PersistentObject>
        Parameters:
        statement - SQL containing bind parameters
        args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type); may also contain SqlParameterValue objects which indicate not only the argument value but also the SQL type and optionally the scale
        Returns:
        the number of rows affected
        Throws:
        PersistenceException - raised in case of errors in the database
      • getSessionFactory

        public org.hibernate.SessionFactory getSessionFactory()