querydsl sub query

多对多关系
List utList = new ArrayList();
				for(Long id : tagIdList){
					UserTag ut = this.userTagService.getDao().findOne(id);
					utList.add(ut);
				}
				QUser qUser = QUser.user;
				QUserTags qUserTags = QUserTags.userTags;
				//添加子查询
				ListSubQuery user = new JPASubQuery()
				  .from(qUserTags)
				  .where(qUserTags.tag.in(utList)).list(qUserTags.user);
				e = (e==null)?e = qUser.in(user):e.and(e = qUser.in(user));

一对多关系:

QDiscussion qDiscussion = QDiscussion.discussion;
			ListSubQuery topic = new JPASubQuery()
			  .from(qDiscussion)
			  .where(qDiscussion.content.contains(discussion)).list(qDiscussion.topic);
			e = (e==null)?e = qTopic.in(topic):e.and(e = qTopic.in(topic));
		}


你可能感兴趣的:(resteasy+maven)