Class BySqlStatic

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

public class BySqlStatic 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.
  • Method Details

    • executeSql

      public int executeSql(String sql)
      execute some sql
      Parameters:
      sql - can be insert, update, delete, or ddl
      Returns:
      the number of rows affected or 0 for ddl
    • 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 - is the types of the params
      Returns:
      the number of rows affected or 0 for ddl
    • select

      public <T> T select(Class<T> returnClassType, String sql)
      select one object from sql (one row, one col
      Type Parameters:
      T - the type
      Parameters:
      returnClassType - type to be returned (currnetly supports string and int
      sql - can be insert, update, delete, or ddl
      Returns:
      the number of rows affected or 0 for ddl
    • select

      @Deprecated public <T> T select(Class<T> returnClassType, String sql, List<Object> params)
      Deprecated.
      doesnt work with postgres, need to pass in param types explicitly since cant determine them if null
      select one object from sql (one row, one col
      Type Parameters:
      T - the type
      Parameters:
      returnClassType - type to be returned (currnetly supports string and int
      sql - can be insert, update, delete, or ddl
      params - prepared statement params
      Returns:
      the number of rows affected or 0 for ddl
    • select

      public <T> T select(Class<T> returnClassType, String sql, List<Object> params, List<org.hibernate.type.Type> types)
      select one object from sql (one row, one col
      Type Parameters:
      T - the type
      Parameters:
      returnClassType - type to be returned (currnetly supports string and int
      sql - can be insert, update, delete, or ddl
      params - prepared statement params
      types - types of params
      Returns:
      the number of rows affected or 0 for ddl
    • listSelectHiberateMapped

      public <T> List<T> listSelectHiberateMapped(Class<T> returnClassType, String query, List<Object> params)
      Deprecated.
      doesnt work with postgres, need to pass in param types explicitly since cant determine them if null
      select one object from sql (one row, one col
      Type Parameters:
      T - the type
      Parameters:
      returnClassType - type to be returned (currnetly supports string and int
      query - can be insert, update, delete, or ddl
      params - prepared statement params
      Returns:
      the number of rows affected or 0 for ddl
    • listSelectHiberateMapped

      public <T> List<T> listSelectHiberateMapped(Class<T> returnClassType, String query, List<Object> params, List<org.hibernate.type.Type> types)
      select one object from sql (one row, one col
      Type Parameters:
      T - the type
      Parameters:
      returnClassType - type to be returned (currnetly supports string and int
      query - can be insert, update, delete, or ddl
      params - prepared statement params
      types - types of params
      Returns:
      the number of rows affected or 0 for ddl
    • listSelect

      @Deprecated public <T> List<T> listSelect(Class<T> returnClassType, String sql, List<Object> params)
      Deprecated.
      doesnt work with postgres, need to pass in param types explicitly since cant determine them if null
      select one object from sql (one row, one col
      Type Parameters:
      T - the type
      Parameters:
      returnClassType - type to be returned (currnetly supports string and int
      sql - can be insert, update, delete, or ddl
      params - prepared statement params
      Returns:
      the number of rows affected or 0 for ddl
    • listSelect

      public <T> List<T> listSelect(Class<T> returnClassType, String sql, List<Object> params, List<org.hibernate.type.Type> types)
      select one object from sql (one row, one col
      Type Parameters:
      T - the type
      Parameters:
      returnClassType - type to be returned (currnetly supports string and int
      sql - can be insert, update, delete, or ddl
      params - prepared statement params
      types -
      Returns:
      the number of rows affected or 0 for ddl
    • attachParams

      @Deprecated public static void attachParams(PreparedStatement statement, Object params) throws org.hibernate.HibernateException, SQLException
      Deprecated.
      doesnt work with postgres, pass in types explicitly
      Attach params for a prepared statement. The type of the params and types must be the same (e.g. either both array or list, but not one is Array, and the other list
      Parameters:
      statement -
      params - either null, Object, Object[], or List of Objects
      Throws:
      org.hibernate.HibernateException
      SQLException
    • convertParamsToTypes

      @Deprecated public static List<org.hibernate.type.Type> convertParamsToTypes(Object params)
      Deprecated.
      doesnt work with postgres. pass in types explicitly
      convert params to types
      Parameters:
      params -
      Returns:
      the types
    • attachParams

      public static void attachParams(PreparedStatement statement, Object params, Object types) throws org.hibernate.HibernateException, SQLException
      Attach params for a prepared statement. The type of the params and types must be the same (e.g. either both array or list, but not one is Array, and the other list
      Parameters:
      statement -
      params - either null, Object, Object[], or List of Objects
      types - either null, Type, Type[], or List of Objects
      Throws:
      org.hibernate.HibernateException
      SQLException