java.lang.Object
edu.internet2.middleware.grouper.hibernate.BySql

public class BySql extends Object
for simple HQL, use this instead of inverse of control. this will do proper error handling and descriptive exception handling. This will by default use the transaction modes GrouperTransactionType.READONLY_OR_USE_EXISTING, and GrouperTransactionType.READ_WRITE_OR_USE_EXISTING depending on if a transaction is needed.
  • Field Details

    • queryCountQueries

      public static int queryCountQueries
      query count exec queries, used for testing
  • Constructor Details

    • BySql

      public BySql(HibernateSession theHibernateSession)
      Parameters:
      theHibernateSession -
  • Method Details

    • setGrouperTransactionType

      public BySql setGrouperTransactionType(GrouperTransactionType theGrouperTransactionType)
      assign a different grouperTransactionType (e.g. for autonomous transactions)
      Parameters:
      theGrouperTransactionType -
      Returns:
      the same object for chaining
    • toString

      public String toString()
      string value for error handling
      Overrides:
      toString in class Object
      Returns:
      the string value
    • createQuery

      public BySql createQuery(String theHqlQuery)
      set the query to run
      Parameters:
      theHqlQuery -
      Returns:
      this object for chaining
    • executeSql

      @Deprecated public int executeSql(String sql, List<Object> params)
      Deprecated.
      doesnt work with postgres, need to pass in param types explicitly since cant determine them if null
      execute some sql
      Parameters:
      sql - can be insert, update, delete, or ddl
      params - prepared statement params
      Returns:
      the number of rows affected or 0 for ddl
    • executeSql

      public int executeSql(String sql, List<Object> params, List<org.hibernate.type.Type> types)
      execute some sql
      Parameters:
      sql - can be insert, update, delete, or ddl
      params - prepared statement params
      types -
      Returns:
      the number of rows affected or 0 for ddl
    • setIgnoreHooks

      public edu.internet2.middleware.grouper.hibernate.ByQueryBase setIgnoreHooks(boolean theIgnoreHooks)
      if we should ignore hooks
      Parameters:
      theIgnoreHooks -
      Returns:
      if we should ignore hooks
    • isIgnoreHooks

      public boolean isIgnoreHooks()
      if we should ignore hooks
      Returns:
      if we should ignore hooks
    • copyFieldsTo

      protected void copyFieldsTo(edu.internet2.middleware.grouper.hibernate.ByQueryBase byQueryBase)
      copy fields from this to the argument
      Parameters:
      byQueryBase -
    • getHibernateSession

      protected HibernateSession getHibernateSession()
      Returns:
      Returns the hibernateSession.
    • set

      protected edu.internet2.middleware.grouper.hibernate.ByQueryBase set(HibernateSession theHibernateSession2)
      set the hibernate session to re-use, or null for a new one byCriteriaStatic().set(hibernateSession2).select(...)
      Parameters:
      theHibernateSession2 - is the session to reuse
      Returns:
      this for chaining
    • main

      public static void main(String[] args)
      Parameters:
      args -