Java Code Examples for org.hibernate.criterion.Restrictions#eq()

The following examples show how to use org.hibernate.criterion.Restrictions#eq() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuestionManagerImpl.java    From DWSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
	public List<Question> findStatsColVarQus(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);
	}
 
Example 2
Source File: TaskAnswerResourceFacadeImp.java    From AIDR with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public boolean deleteTaskAnswer(Long documentID) {
	
	try {
		Criterion criterion = Restrictions.eq("id.documentId", documentID);
		List<TaskAnswer> answers = getAllByCriteria(criterion);
		if(answers != null) {
			
			// delete task
			for (TaskAnswer taskAnswer : answers) {
				delete(taskAnswer);
			}
		}
		return true;
	} catch (Exception e) {
		logger.error("Error in deleting taskAnswer give documentID : " + documentID);
		return false;
	}
}
 
Example 3
Source File: DefaultSshKeyManager.java    From onedev with MIT License 5 votes vote down vote up
@Sessional
@Override
public SshKey findByDigest(String digest) {
    SimpleExpression eq = Restrictions.eq("digest", digest);
    EntityCriteria<SshKey> entityCriteria = EntityCriteria.of(SshKey.class).add(eq);
    entityCriteria.setCacheable(true);
    return find(entityCriteria);
}
 
Example 4
Source File: SurveyDetailManagerImpl.java    From DWSurvey with GNU Affero General Public License v3.0 5 votes vote down vote up
private SurveyDetail findUn(String dirId){
	Criterion criterion=Restrictions.eq("dirId", dirId);
	 List<SurveyDetail> details=surveyDetailDao.find(criterion);
	 if(details!=null && details.size()>0){
		 return details.get(0);
	 }
	 return null;
}
 
Example 5
Source File: SurveyAnswerManagerImpl.java    From DWSurvey with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public List<SurveyAnswer> answersByIp(String surveyId, String ip) {
	Criterion criterionSurveyId = Restrictions.eq("surveyId", surveyId);
	Criterion criterionIp = Restrictions.eq("ipAddr", ip);
	List<SurveyAnswer> answers = surveyAnswerDao.find(criterionSurveyId,
			criterionIp);
	return answers;
}
 
Example 6
Source File: SurveyAnswerManagerImpl.java    From DWSurvey with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 取一份卷子回答的数据
 */
public Page<SurveyAnswer> answerPage(Page<SurveyAnswer> page,String surveyId){
	Criterion cri1=Restrictions.eq("surveyId", surveyId);
	Criterion cri2=Restrictions.lt("handleState", 2);
	page.setOrderBy("endAnDate");
	page.setOrderDir("desc");
	page=findPage(page, cri1, cri2);
	return page;
}
 
Example 7
Source File: QuOrderbyManagerImpl.java    From DWSurvey with GNU Affero General Public License v3.0 5 votes vote down vote up
public int getOrderById(String quId){
	Criterion criterion=Restrictions.eq("quId", quId);
	QuOrderby quOrderby=quOrderbyDao.findFirst("orderById", false, criterion);
	if(quOrderby!=null){
		return quOrderby.getOrderById();
	}
	return 0;
}
 
Example 8
Source File: CriteriaVisitor.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public Object visit(PropertyIsEqualTo filter, Object userData) {
	String propertyName = getPropertyName(filter.getExpression1());
	String finalName = parsePropertyName(propertyName, userData);

	Object value = castLiteral(getLiteralValue(filter.getExpression2()), propertyName);
	return Restrictions.eq(finalName, value);
}
 
Example 9
Source File: HibernateUtil.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static List<BasicRule> getAllOtherPublishedBasicRules(String userID) {
    Session session = getSessionFactory().getCurrentSession();
    session.beginTransaction();
    Criteria crit = session.createCriteria(BasicRule.class);
    Criterion isOwner = Restrictions.not(Restrictions.eq(OWNER_ID, valueOf(userID)));
    SimpleExpression isPublished = Restrictions.eq(PUBLISHED, true);
    List<BasicRule> rules = crit.add(Restrictions.and(isOwner, isPublished)).list();
    session.getTransaction().commit();
    return rules;
}
 
Example 10
Source File: AnChenCheckboxManagerImpl.java    From DWSurvey with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public List<AnChenCheckbox> findAnswer(String belongAnswerId, String quId) {//belongAnswerId quId
	Criterion criterion1=Restrictions.eq("belongAnswerId", belongAnswerId);
	Criterion criterion2=Restrictions.eq("quId", quId);
	return anChenCheckboxDao.find(criterion1,criterion2);
}
 
Example 11
Source File: QuestionLogicManagerImpl.java    From DWSurvey with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public List<QuestionLogic> findByCkQuId(String ckQuId) {
	Criterion cri1=Restrictions.eq("ckQuId", ckQuId);
	Criterion cri2=Restrictions.eq("visibility", 1);
	return questionLogicDao.find(cri1,cri2);
}
 
Example 12
Source File: AnYesnoManagerImpl.java    From DWSurvey with GNU Affero General Public License v3.0 4 votes vote down vote up
public AnYesno findAnswer(String belongAnswerId,String quId){
	//belongAnswerId quId
	Criterion criterion1=Restrictions.eq("belongAnswerId", belongAnswerId);
	Criterion criterion2=Restrictions.eq("quId", quId);
	return anYesnoDao.findUnique(criterion1,criterion2);
}
 
Example 13
Source File: PullRequest.java    From onedev with MIT License 4 votes vote down vote up
public static Criterion ofSubmitter(User submitter) {
	return Restrictions.eq("submitter", submitter);
}
 
Example 14
Source File: RdrSetLoader.java    From yawl with GNU Lesser General Public License v3.0 4 votes vote down vote up
private RdrSet loadSet(String column, String value) {
    Criterion criterion = Restrictions.eq(column, value);
    List list = Persister.getInstance().getByCriteria(RdrSet.class, criterion);
    return ! (list == null || list.isEmpty()) ? (RdrSet) list.get(0) : null;
}
 
Example 15
Source File: AnDFillblankManagerImpl.java    From DWSurvey with GNU Affero General Public License v3.0 4 votes vote down vote up
public List<AnDFillblank> findAnswer(String belongAnswerId,String quId){
	//belongAnswerId quId
	Criterion criterion1=Restrictions.eq("belongAnswerId", belongAnswerId);
	Criterion criterion2=Restrictions.eq("quId", quId);
	return anDFillblankDao.find(criterion1,criterion2);
}
 
Example 16
Source File: TaskQueueDaoImpl.java    From AIDR with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public List<TaskQueue> findLatestTaskQueue(Long clientAppID) {
    Criterion criterion = Restrictions.eq("clientAppID",clientAppID);
    return getMaxOrderByCriteria(criterion, "updated");
}
 
Example 17
Source File: PullRequest.java    From onedev with MIT License 4 votes vote down vote up
public static Criterion ofTargetProject(Project target) {
	return Restrictions.eq("targetProject", target);
}
 
Example 18
Source File: UserManagerImpl.java    From DWSurvey with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public User findByCode(String code) {
	Criterion criterion=Restrictions.eq("findPwdCode", code);
	return userDao.findFirst(criterion);
}
 
Example 19
Source File: AnOrderManagerImpl.java    From DWSurvey with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public List<AnOrder> findAnswer(String belongAnswerId, String quId) {//belongAnswerId quId
	Criterion criterion1=Restrictions.eq("belongAnswerId", belongAnswerId);
	Criterion criterion2=Restrictions.eq("quId", quId);
	return anOrderDao.find(criterion1,criterion2);
}
 
Example 20
Source File: HibernateUtils.java    From lemon with Apache License 2.0 2 votes vote down vote up
/**
 * 按属性条件参数创建Criterion,辅助函数.
 * 
 * @param propertyName
 *            String
 * @param propertyValue
 *            Object
 * @param matchType
 *            MatchType
 * @return Criterion
 */
public static Criterion buildCriterion(String propertyName,
        Object propertyValue, MatchType matchType) {
    Assert.hasText(propertyName, "propertyName不能为空");

    Criterion criterion = null;

    // 根据MatchType构造criterion
    switch (matchType) {
    case EQ:
        criterion = Restrictions.eq(propertyName, propertyValue);

        break;

    case NOT:
        criterion = Restrictions.ne(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 IN:
        criterion = Restrictions.in(propertyName,
                (Collection) propertyValue);

        break;

    case INL:
        criterion = Restrictions.isNull(propertyName);

        break;

    case NNL:
        criterion = Restrictions.isNotNull(propertyName);

        break;

    default:
        criterion = Restrictions.eq(propertyName, propertyValue);

        break;
    }

    return criterion;
}