edu.internet2.middleware.grouper.hibernate
Class BySqlStatic

java.lang.Object
  extended by 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.

Author:
mchyzer

Method Summary
static void attachParams(PreparedStatement statement, Object params)
          Attach params for a prepared statement.
static void attachParams(PreparedStatement statement, Object params, Object types)
          Attach params for a prepared statement.
 int executeSql(String sql)
          execute some sql
 int executeSql(String sql, List<Object> params)
          execute some sql
<T> List<T>
listSelect(Class<T> returnClassType, String sql, List<Object> params)
          select one object from sql (one row, one col
<T> List<T>
listSelectHiberateMapped(Class<T> returnClassType, String query, List<Object> params)
          select one object from sql (one row, one col
<T> T
select(Class<T> returnClassType, String sql)
          select one object from sql (one row, one col
<T> T
select(Class<T> returnClassType, String sql, List<Object> params)
          select one object from sql (one row, one col
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

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

public int executeSql(String sql,
                      List<Object> params)
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

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

public <T> T select(Class<T> returnClassType,
                    String sql,
                    List<Object> params)
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

listSelectHiberateMapped

public <T> List<T> listSelectHiberateMapped(Class<T> returnClassType,
                                            String query,
                                            List<Object> params)
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)
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

attachParams

public static void attachParams(PreparedStatement statement,
                                Object params)
                         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
Throws:
org.hibernate.HibernateException
SQLException

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