Class BaseHelper


  • @Component
    public class BaseHelper
    extends Object
    Core functionality needed in all members of SQL service family. Taken out of SqlBaseService in order to be accessible from other components by autowiring.

    Originally more Hibernate oriented, some pure JDBC parts are added (newJdbcSession() and dataSource field) which may be basis of pure JDBC repository in the future. It may go away from this class, but for now, hybrid approach is chosen. But while helper methods are used for ORM/Hibernate stuff, after creating JdbcSession all other methods are called on the returned object.

    • Field Detail

      • LOCKING_MAX_RETRIES

        public static final int LOCKING_MAX_RETRIES
        How many times we want to repeat operation after lock acquisition, pessimistic, optimistic exception.
        See Also:
        Constant Field Values
      • LOCKING_DELAY_INTERVAL_BASE

        public static final long LOCKING_DELAY_INTERVAL_BASE
        Timeout will be a random number between 0 and LOCKING_DELAY_INTERVAL_BASE * 2^exp where exp is either real attempt # minus 1, or LOCKING_EXP_THRESHOLD (whatever is lesser).
        See Also:
        Constant Field Values
    • Constructor Detail

      • BaseHelper

        @Autowired
        public BaseHelper​(SqlRepositoryFactory repositoryFactory,
                          org.hibernate.SessionFactory sessionFactory,
                          DataSource dataSource)
    • Method Detail

      • getSessionFactory

        public org.hibernate.SessionFactory getSessionFactory()
      • beginReadOnlyTransaction

        public org.hibernate.Session beginReadOnlyTransaction()
      • beginTransaction

        public org.hibernate.Session beginTransaction()
      • beginTransaction

        public org.hibernate.Session beginTransaction​(String startTransactionStatement)
      • cleanupSessionAndResult

        public void cleanupSessionAndResult​(org.hibernate.Session session,
                                            OperationResult result)
      • handleGeneralException

        public void handleGeneralException​(Throwable ex,
                                           org.hibernate.Session session,
                                           OperationResult result)
      • handleGeneralRuntimeException

        public void handleGeneralRuntimeException​(RuntimeException ex,
                                                  org.hibernate.Session session,
                                                  OperationResult result)
      • handleGeneralCheckedException

        public void handleGeneralCheckedException​(Throwable ex,
                                                  org.hibernate.Session session,
                                                  OperationResult result)
      • querydslConfiguration

        public com.querydsl.sql.Configuration querydslConfiguration()
      • newJdbcSession

        public JdbcSession newJdbcSession()
        Creates JdbcSession that typically represents transactional work on JDBC connection. All other lifecycle methods are to be called on the returned object. Object is AutoCloseable and can be used in try-with-resource blocks.