本文整理匯總了Java中org.hibernate.criterion.DetachedCriteria.getExecutableCriteria方法的典型用法代碼示例。如果您正苦於以下問題:Java DetachedCriteria.getExecutableCriteria方法的具體用法?Java DetachedCriteria.getExecutableCriteria怎麽用?Java DetachedCriteria.getExecutableCriteria使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.hibernate.criterion.DetachedCriteria
的用法示例。
在下文中一共展示了DetachedCriteria.getExecutableCriteria方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: listCriteria
import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings ("unchecked")
public List<T> listCriteria (DetachedCriteria detached, int skip, int top)
{
SessionFactory factory = getSessionFactory ();
org.hibernate.classic.Session session = factory.getCurrentSession ();
Criteria criteria = detached.getExecutableCriteria (session);
if (skip > 0)
criteria.setFirstResult (skip);
if (top > 0)
criteria.setMaxResults (top);
return criteria.list ();
}
示例2: execute
import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
private Object execute(FlowFinderCriteria flowFinderCriteria,
DetachedCriteria flowStatusCriteria, Session session,
boolean idProjection) {
Criteria criteria = flowStatusCriteria.getExecutableCriteria(session);
if (idProjection) {
criteria.setProjection(Projections.id());
}
int maxResults = flowFinderCriteria.getMaxResults();
if (maxResults != FlowFinderCriteria.DEFAULT_MAX_RESULTS) {
criteria.setMaxResults(maxResults);
}
if (flowFinderCriteria.hasMessageQuery()) {
FlowSearchCriteria flowSearchCriteria = new FlowSearchCriteria();
flowSearchCriteria.setHibernateCriteria(criteria);
flowSearchCriteria.setInboundMessageQuery(flowFinderCriteria.getInboundMessageQuery());
flowSearchCriteria.setOutboundMessageQuery(flowFinderCriteria.getOutboundMessageQuery());
return flowSearchCallback.findFlows(session, flowSearchCriteria);
} else {
return criteria.list();
}
}
示例3: deleteComponentProfileByControlId
import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void deleteComponentProfileByControlId(String controlId, String name) {
DetachedCriteria detachedCriteria = DetachedCriteria.forClass(ComponentConfig.class);
detachedCriteria.add(Restrictions.eq("controlId", controlId));
detachedCriteria.add(Restrictions.eq("name", name));
Session session = this.getSessionFactory().openSession();
try {
org.hibernate.Criteria criteria = detachedCriteria.getExecutableCriteria(session);
List<ComponentConfig> list = criteria.list();
if (list.size() > 0) {
String hql = "delete " + ComponentConfigMember.class.getName()
+ " m where m.componentConfig.id = :configId";
session.createQuery(hql).setString("configId", list.get(0).getId()).executeUpdate();
session.delete(list.get(0));
}
} finally {
session.flush();
session.close();
}
}
示例4: uniqueResult
import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings ("unchecked")
public T uniqueResult (DetachedCriteria criteria)
{
Criteria excrit = criteria.getExecutableCriteria(getSessionFactory().getCurrentSession());
excrit.setMaxResults(1);
List<?> res = excrit.list();
return res.isEmpty() ? null : (T) res.get(0);
}
示例5: count
import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
public int count (DetachedCriteria detached)
{
Session session = getSessionFactory ().getCurrentSession ();
Criteria criteria = detached.getExecutableCriteria (session);
criteria.setProjection(Projections.rowCount());
Object result = criteria.uniqueResult ();
return ((Number) result).intValue ();
}
示例6: findByCriteria
import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public List findByCriteria(final DetachedCriteria detachedCriteria) throws Exception {
Session session=this.getSessionFactory(dataSourceRegisterName).openSession();
try{
org.hibernate.Criteria criteria = detachedCriteria.getExecutableCriteria(session);
return criteria.list();
}finally{
session.flush();
session.close();
}
}
示例7: queryCount
import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public int queryCount(DetachedCriteria detachedCriteria,String dataSourceName){
Session session=this.getSessionFactory(dataSourceName).openSession();
try{
org.hibernate.Criteria criteria=detachedCriteria.getExecutableCriteria(session);
try {
Field field = CriteriaImpl.class.getDeclaredField("orderEntries");
field.setAccessible(true);
field.set(criteria,new ArrayList());
} catch (Exception e) {
e.printStackTrace();
}
int totalCount=0;
Object totalObject=criteria.setProjection(Projections.rowCount()).uniqueResult();
if(totalObject instanceof Integer){
totalCount=(Integer)totalObject;
}else if(totalObject instanceof Long){
totalCount=((Long)totalObject).intValue();
}else if (totalObject != null) {
throw new RuntimeException("Can not convert ["+totalObject+"] to a int value when query entity total count!");
}
return totalCount;
}finally{
session.flush();
session.close();
}
}
示例8: queryCount
import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public int queryCount(DetachedCriteria detachedCriteria, String dataSourceName) {
Session session = this.getSessionFactory(dataSourceName).openSession();
try {
org.hibernate.Criteria criteria = detachedCriteria.getExecutableCriteria(session);
try {
Field field = CriteriaImpl.class.getDeclaredField("orderEntries");
field.setAccessible(true);
field.set(criteria, new ArrayList());
} catch (Exception e) {
e.printStackTrace();
}
int totalCount = 0;
Object totalObject = criteria.setProjection(Projections.rowCount()).uniqueResult();
if (totalObject instanceof Integer) {
totalCount = (Integer) totalObject;
} else if (totalObject instanceof Long) {
totalCount = ((Long) totalObject).intValue();
} else if (totalObject != null) {
throw new RuntimeException("Can not convert [" + totalObject
+ "] to a int value when query entity total count!");
}
return totalCount;
} finally {
session.flush();
session.close();
}
}