本文整理汇总了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();
}
}