本文整理汇总了Java中org.hibernate.criterion.Criterion类的典型用法代码示例。如果您正苦于以下问题:Java Criterion类的具体用法?Java Criterion怎么用?Java Criterion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Criterion类属于org.hibernate.criterion包,在下文中一共展示了Criterion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildCriterion
import org.hibernate.criterion.Criterion; //导入依赖的package包/类
/**
* 按属性条件参数创建Criterion,辅助函数.
*/
protected Criterion buildCriterion(final String propertyName, final Object propertyValue, final MatchType matchType) {
AssertUtils.hasText(propertyName, "propertyName不能为空");
Criterion criterion = null;
//根据MatchType构造criterion
switch (matchType) {
case EQ:
criterion = Restrictions.eq(propertyName, propertyValue);
break;
case LIKE:
criterion = Restrictions.like(propertyName, (String) propertyValue, MatchMode.ANYWHERE);
break;
case LE:
criterion = Restrictions.le(propertyName, propertyValue);
break;
case LT:
criterion = Restrictions.lt(propertyName, propertyValue);
break;
case GE:
criterion = Restrictions.ge(propertyName, propertyValue);
break;
case GT:
criterion = Restrictions.gt(propertyName, propertyValue);
break;
case NE:
criterion = Restrictions.ne(propertyName, propertyValue);
}
return criterion;
}
示例2: buildCriterions
import org.hibernate.criterion.Criterion; //导入依赖的package包/类
private void buildCriterions(Collection<com.bstek.dorado.data.provider.Criterion> criterions,
org.hibernate.criterion.Junction dc) {
for (com.bstek.dorado.data.provider.Criterion c : criterions) {
if (c instanceof SingleValueFilterCriterion) {
SingleValueFilterCriterion fc = (SingleValueFilterCriterion) c;
dc.add(this.buildCriterion(fc));
}
if (c instanceof Junction) {
Junction jun = (Junction) c;
org.hibernate.criterion.Junction junction = null;
if (jun instanceof Or) {
junction = Restrictions.disjunction();
} else if (jun instanceof And) {
junction = Restrictions.conjunction();
}
Collection<com.bstek.dorado.data.provider.Criterion> subCriterions = jun.getCriterions();
if (subCriterions != null) {
buildCriterions(subCriterions, dc);
}
dc.add(junction);
}
}
}
示例3: createCriteria
import org.hibernate.criterion.Criterion; //导入依赖的package包/类
/**
* 根据entityClass,生成带排序的Criteria.
*
* @param <T>
* 实体类型
* @param entityClass
* 类型
* @param orderBy
* 排序字段名
* @param isAsc
* 是否正序
* @param criterions
* 条件
* @return Criteria
*/
public <T> Criteria createCriteria(Class<T> entityClass, String orderBy,
boolean isAsc, Criterion... criterions) {
if (StringUtils.hasText(orderBy)) {
Criteria criteria = createCriteria(entityClass, criterions);
if (isAsc) {
criteria.addOrder(Order.asc(orderBy));
} else {
criteria.addOrder(Order.desc(orderBy));
}
return criteria;
} else {
return createCriteria(entityClass, criterions);
}
}
示例4: getTimeInByIp
import org.hibernate.criterion.Criterion; //导入依赖的package包/类
@Override
public SurveyAnswer getTimeInByIp(SurveyDetail surveyDetail, String ip) {
String surveyId = surveyDetail.getDirId();
Criterion eqSurveyId = Restrictions.eq("surveyId", surveyId);
Criterion eqIp = Restrictions.eq("ipAddr", ip);
int minute = surveyDetail.getEffectiveTime();
Date curdate = new Date();
Calendar calendarDate = Calendar.getInstance();
calendarDate.setTime(curdate);
calendarDate.set(Calendar.MINUTE, calendarDate.get(Calendar.MINUTE)
- minute);
Date date = calendarDate.getTime();
Criterion gtEndDate = Restrictions.gt("endAnDate", date);
return surveyAnswerDao.findFirst("endAnDate", true, eqSurveyId, eqIp,
gtEndDate);
}
示例5: findStatsRowVarQus
import org.hibernate.criterion.Criterion; //导入依赖的package包/类
@Override
public List<Question> findStatsRowVarQus(SurveyDirectory survey) {
Criterion criterion1=Restrictions.eq("belongId", survey.getId());
Criterion criterion2=Restrictions.eq("tag", 2);
// Criterion criterion31=Restrictions.ne("quType", QuType.FILLBLANK);
// Criterion criterion32=Restrictions.ne("quType", QuType.MULTIFILLBLANK);
// Criterion criterion33=Restrictions.ne("quType", QuType.ANSWER);
//
//// Criterion criterion3=Restrictions.or(criterion31, criterion32);
// //where s=2 and (fds !=1 or fds!=2 )
// return questionDao.find(criterion1,criterion2,criterion31,criterion32,criterion33);
Criterion criterion31=Restrictions.ne("quType", QuType.FILLBLANK);
Criterion criterion32=Restrictions.ne("quType", QuType.MULTIFILLBLANK);
Criterion criterion33=Restrictions.ne("quType", QuType.ANSWER);
Criterion criterion34=Restrictions.ne("quType", QuType.CHENCHECKBOX);
Criterion criterion35=Restrictions.ne("quType", QuType.CHENFBK);
Criterion criterion36=Restrictions.ne("quType", QuType.CHENRADIO);
Criterion criterion37=Restrictions.ne("quType", QuType.ENUMQU);
Criterion criterion38=Restrictions.ne("quType", QuType.ORDERQU);
Criterion criterion39=Restrictions.ne("quType", QuType.SCORE);
return questionDao.find(criterion1,criterion2,criterion31,criterion32,criterion33,criterion34,criterion35,criterion36,criterion37,criterion38,criterion39);
// return null;
}
示例6: findPage
import org.hibernate.criterion.Criterion; //导入依赖的package包/类
@Override
public Page<QuestionBank> findPage(Page<QuestionBank> page, QuestionBank entity) {
page.setOrderBy("createDate");
page.setOrderDir("desc");
List<Criterion> criterions=new ArrayList<Criterion>();
criterions.add(Restrictions.eq("visibility", 1));
criterions.add(Restrictions.eq("dirType", 2));
criterions.add(Restrictions.eq("bankState", 1));
Integer bankTag = entity.getBankTag();
if(bankTag==null){
bankTag=0;
}
criterions.add(Restrictions.eq("bankTag", bankTag));
String groupId1 = entity.getGroupId1();
String groupId2 = entity.getGroupId2();
if(groupId1!=null && !"".equals(groupId1)){
criterions.add(Restrictions.eq("groupId1", groupId1));
}
if(groupId2!=null && !"".equals(groupId2)){
criterions.add(Restrictions.eq("groupId2", groupId2));
}
return questionBankDao.findPageList(page, criterions);
}
示例7: createCriteria
import org.hibernate.criterion.Criterion; //导入依赖的package包/类
/**
* 创建Criteria对象
* @param criterions 可变条件Restrictions<br />
* criteria.add(Restrictions.eq(propertyName, value));
* @return Criteria
*/
protected Criteria createCriteria(Criterion... criterions)
{
//final Class _class = getEntityClass();
Criteria criteria = (Criteria)getHibernateTemplate().execute(new HibernateCallback()
{
public Criteria doInHibernate(Session session) throws HibernateException//, SQLException
{
//return session.createCriteria(_class);
return session.createCriteria(getEntityClass());
}
});// QBC方式
for(Criterion c : criterions)
{
criteria.add(c);
}
return criteria;
}
示例8: userDeletedEvent
import org.hibernate.criterion.Criterion; //导入依赖的package包/类
@Transactional
@Override
public void userDeletedEvent(UserDeletedEvent event)
{
// The super behaviour is to orphan things and we want most OAuthClients
// to stick around, so let owned ones be orphaned first.
super.userDeletedEvent(event);
// ...but, clients that are locked to the user being deleted are
// useless, so we'll delete those.
Criterion c1 = Restrictions.eq("userId", event.getUserID());
Criterion c2 = Restrictions.eq("institution", CurrentInstitution.get());
for( OAuthClient oc : clientDao.findAllByCriteria(c1, c2) )
{
delete(oc, false);
}
tokenDao.deleteAllForUser(event.getUserID());
}
示例9: toSqlString
import org.hibernate.criterion.Criterion; //导入依赖的package包/类
@Override
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException
{
StringBuilder buffer = new StringBuilder();
buffer.append('(');
int i = 0;
for( Criterion crit : criterion )
{
if( i != 0 )
{
buffer.append(' ');
buffer.append(op);
buffer.append(' ');
}
buffer.append(crit.toSqlString(criteria, criteriaQuery));
i++;
}
buffer.append(')');
return buffer.toString();
}
示例10: enumerateCategories
import org.hibernate.criterion.Criterion; //导入依赖的package包/类
@Override
public Set<String> enumerateCategories()
{
Criterion crit = getInstitutionCriterion();
Set<String> results = new TreeSet<String>(Format.STRING_COMPARATOR);
for( ItemDefinition itemdef : getDao().findAllByCriteria(crit) )
{
String category = itemdef.getWizardcategory();
if( category != null )
{
results.add(category);
}
}
return results;
}
示例11: Subcriteria
import org.hibernate.criterion.Criterion; //导入依赖的package包/类
private Subcriteria(Criteria parent, String path, String alias, JoinType joinType, Criterion withClause) {
this.alias = alias;
this.path = path;
this.parent = parent;
this.joinType = joinType;
this.withClause = withClause;
this.hasRestriction = withClause != null;
CriteriaImpl.this.subcriteriaList.add( this );
}
示例12: delete
import org.hibernate.criterion.Criterion; //导入依赖的package包/类
@Transactional
public void delete(SurveyDirectory parentDirectory) {
String id=parentDirectory.getId();
//目录ID,为1的为系统默认注册用户目录不能删除
if(!"1".equals(id)){
//设为不可见
parentDirectory.setVisibility(0);
Criterion criterion=Restrictions.eq("parentId", parentDirectory.getId());
List<SurveyDirectory> directories=findList(criterion);
if(directories!=null){
for (SurveyDirectory surveyDirectory : directories) {
delete(surveyDirectory);
}
}
}
}
示例13: findByCriteria
import org.hibernate.criterion.Criterion; //导入依赖的package包/类
protected List<T> findByCriteria(Criterion... criterion) {
Criteria crit = getSession().createCriteria(getPersistentClass());
for (Criterion c : criterion) {
crit.add(c);
}
return crit.list();
}
示例14: findByIndex
import org.hibernate.criterion.Criterion; //导入依赖的package包/类
@Override
public List<SurveyDirectory> findByIndex() {
Criterion cri1=Restrictions.eq("visibility", 1);
Criterion cri2=Restrictions.eq("parentId", "402880e5428a2dca01428a2f1f290000");
Criterion cri3=Restrictions.eq("surveyTag", 1);
Criterion cri4=Restrictions.isNull("sid");
Page<SurveyDirectory> page=new Page<SurveyDirectory>();
page.setOrderBy("createDate");
page.setOrderDir("desc");
page.setPageSize(10);
List<SurveyDirectory> surveys = surveyDirectoryDao.findPage(page, cri1,cri2,cri3,cri4).getResult();
return surveys;
}
示例15: getPgsByRole
import org.hibernate.criterion.Criterion; //导入依赖的package包/类
public List<Pg> getPgsByRole(String role){
logger.debug("IN - role: {}", role);
Criterion whereRole = Restrictions.eq("role.role", role);
List<Pg> pg = getSession()
.createCriteria(Pg.class)
.createAlias("roles", "role")
.add(whereRole)
.list();
return pg;
}