📄 _baserootdao.java
字号:
if (null != defaultOrder)
crit.addOrder(defaultOrder);
return crit.list();
}
/**
* Return all objects related to the implementation of this DAO with a filter.
* Use the session given.
*
* @param propName
* the name of the property to use for filtering
* @param filter
* the value of the filter
*/
protected Criteria findFiltered(String propName, Object filter)
{
return findFiltered(propName, filter, getDefaultOrder());
}
/**
* Return all objects related to the implementation of this DAO with a filter.
* Use the session given.
*
* @param propName
* the name of the property to use for filtering
* @param filter
* the value of the filter
* @param orderProperty
* the name of the property used for ordering
*/
protected Criteria findFiltered(String propName, Object filter, Order order)
{
Session s = null;
try
{
s = getSession();
return findFiltered(s, propName, filter, order);
}
finally
{
closeSession(s);
}
}
/**
* Return all objects related to the implementation of this DAO with a filter.
* Use the session given.
*
* @param s
* the Session
* @param propName
* the name of the property to use for filtering
* @param filter
* the value of the filter
* @param orderProperty
* the name of the property used for ordering
*/
protected Criteria findFiltered(Session s, String propName, Object filter,
Order order)
{
Criteria crit = s.createCriteria(getReferenceClass());
crit.add(Expression.eq(propName, filter));
if (null != order)
crit.addOrder(order);
return crit;
}
/**
* Obtain an instance of Query for a named query string defined in the mapping
* file.
*
* @param name
* the name of a query defined externally
* @return Query
*/
protected Query getNamedQuery(String name)
{
Session s = null;
try
{
s = getSession();
return getNamedQuery(name, s);
}
finally
{
closeSession(s);
}
}
/**
* Obtain an instance of Query for a named query string defined in the mapping
* file. Use the session given.
*
* @param name
* the name of a query defined externally
* @param s
* the Session
* @return Query
*/
protected Query getNamedQuery(String name, Session s)
{
Query q = s.getNamedQuery(name);
return q;
}
/**
* Obtain an instance of Query for a named query string defined in the mapping
* file.
*
* @param name
* the name of a query defined externally
* @param param
* the first parameter to set
* @return Query
*/
protected Query getNamedQuery(String name, Serializable param)
{
Session s = null;
try
{
s = getSession();
return getNamedQuery(name, param, s);
}
finally
{
closeSession(s);
}
}
/**
* Obtain an instance of Query for a named query string defined in the mapping
* file. Use the session given.
*
* @param name
* the name of a query defined externally
* @param param
* the first parameter to set
* @param s
* the Session
* @return Query
*/
protected Query getNamedQuery(String name, Serializable param, Session s)
{
Query q = s.getNamedQuery(name);
q.setParameter(0, param);
return q;
}
/**
* Obtain an instance of Query for a named query string defined in the mapping
* file. Use the parameters given.
*
* @param name
* the name of a query defined externally
* @param params
* the parameter array
* @return Query
*/
protected Query getNamedQuery(String name, Serializable[] params)
{
Session s = null;
try
{
s = getSession();
return getNamedQuery(name, params, s);
}
finally
{
closeSession(s);
}
}
/**
* Obtain an instance of Query for a named query string defined in the mapping
* file. Use the parameters given and the Session given.
*
* @param name
* the name of a query defined externally
* @param params
* the parameter array
* @s the Session
* @return Query
*/
protected Query getNamedQuery(String name, Serializable[] params, Session s)
{
Query q = s.getNamedQuery(name);
if (null != params)
{
for (int i = 0; i < params.length; i++)
{
q.setParameter(i, params[i]);
}
}
return q;
}
/**
* Obtain an instance of Query for a named query string defined in the mapping
* file. Use the parameters given.
*
* @param name
* the name of a query defined externally
* @param params
* the parameter Map
* @return Query
*/
protected Query getNamedQuery(String name, Map params)
{
Session s = null;
try
{
s = getSession();
return getNamedQuery(name, params, s);
}
finally
{
closeSession(s);
}
}
/**
* Obtain an instance of Query for a named query string defined in the mapping
* file. Use the parameters given and the Session given.
*
* @param name
* the name of a query defined externally
* @param params
* the parameter Map
* @s the Session
* @return Query
*/
protected Query getNamedQuery(String name, Map params, Session s)
{
Query q = s.getNamedQuery(name);
if (null != params)
{
for (Iterator i = params.entrySet().iterator(); i.hasNext();)
{
Map.Entry entry = (Map.Entry) i.next();
q.setParameter((String) entry.getKey(), entry.getValue());
}
}
return q;
}
/**
* Execute a query.
*
* @param queryStr
* a query expressed in Hibernate's query language
* @return a distinct list of instances (or arrays of instances)
*/
public Query getQuery(String queryStr)
{
Session s = null;
try
{
s = getSession();
return getQuery(queryStr, s);
}
finally
{
closeSession(s);
}
}
/**
* Execute a query but use the session given instead of creating a new one.
*
* @param queryStr
* a query expressed in Hibernate's query language
* @s the Session to use
*/
public Query getQuery(String queryStr, Session s)
{
return s.createQuery(queryStr);
}
/**
* Execute a query.
*
* @param query
* a query expressed in Hibernate's query language
* @param queryStr
* the name of a query defined externally
* @param param
* the first parameter to set
* @return Query
*/
protected Query getQuery(String queryStr, Serializable param)
{
Session s = null;
try
{
s = getSession();
return getQuery(queryStr, param, s);
}
finally
{
closeSession(s);
}
}
/**
* Execute a query but use the session given instead of creating a new one.
*
* @param queryStr
* a query expressed in Hibernate's query language
* @param param
* the first parameter to set
* @s the Session to use
* @return Query
*/
protected Query getQuery(String queryStr, Serializable param, Session s)
{
Query q = getQuery(queryStr, s);
q.setParameter(0, param);
return q;
}
/**
* Execute a query.
*
* @param queryStr
* a query expressed in Hibernate's query language
* @param params
* the parameter array
* @return Query
*/
protected Query getQuery(String queryStr, Serializable[] params)
{
Session s = null;
try
{
s = getSession();
return getQuery(queryStr, params, s);
}
finally
{
closeSession(s);
}
}
/**
* Execute a query but use the session given instead of creating a new one.
*
* @param queryStr
* a query expressed in Hibernate's query language
* @param params
* the parameter array
* @s the Session
* @return Query
*/
protected Query getQuery(String queryStr, Serializable[] params, Session s)
{
Query q = getQuery(queryStr, s);
if (null != params)
{
for (int i = 0; i < params.length; i++)
{
q.setParameter(i, params[i]);
}
}
return q;
}
/**
* Obtain an instance of Query for a named query string defined in the mapping
* file. Use the parameters given.
*
* @param queryStr
* a query expressed in Hibernate's query language
* @param params
* the parameter Map
* @return Query
*/
protected Query getQuery(String queryStr, Map params)
{
Session s = null;
try
{
s = getSession();
return getQuery(queryStr, params, s);
}
finally
{
closeSession(s);
}
}
/**
* Obtain an instance of Query for a named query string defined in the mapping
* file. Use the parameters given and the Session given.
*
* @param queryStr
* a query expressed in Hibernate's query language
* @param params
* the parameter Map
* @s the Session
* @return Query
*/
protected Query getQuery(String queryStr, Map params, Session s)
{
Query q = getQuery(queryStr, s);
if (null != params)
{
for (Iterator i = params.entrySet().iterator(); i.hasNext();)
{
Map.Entry entry = (Map.Entry) i.next();
q.setParameter((String) entry.getKey(), entry.getValue());
}
}
return q;
}
protected Order getDefaultOrder()
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -