本文整理汇总了Java中javax.persistence.criteria.CriteriaBuilder.In类的典型用法代码示例。如果您正苦于以下问题:Java In类的具体用法?Java In怎么用?Java In使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
In类属于javax.persistence.criteria.CriteriaBuilder包,在下文中一共展示了In类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findOrgTypesForScope
import javax.persistence.criteria.CriteriaBuilder.In; //导入依赖的package包/类
@Override
public List<OrgTypeDO> findOrgTypesForScope(Long scopeId, Collection<String> orgTypeCodes) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<OrgTypeDO> criteria = cb.createQuery(OrgTypeDO.class);
Root<OrgTypeDO> root = criteria.from(OrgTypeDO.class);
criteria.where(cb.equal(root.get(OrgTypeDO_.scope).get(ScopeDO_.scopeId), scopeId));
In<String> inOrgTypeCode = cb.in(root.get(OrgTypeDO_.code));
if (orgTypeCodes.isEmpty()) {
inOrgTypeCode.value((String) null);
} else {
for (String orgTypeCode : orgTypeCodes) {
inOrgTypeCode.value(orgTypeCode);
}
}
criteria.where(inOrgTypeCode);
TypedQuery<OrgTypeDO> query = em.createQuery(criteria);
query.setHint("org.hibernate.cacheable", Boolean.TRUE);
return query.getResultList();
}
示例2: whereIn
import javax.persistence.criteria.CriteriaBuilder.In; //导入依赖的package包/类
/**
* 包含
*
* @param propertyName 属性名称
* @param values 参数集合
* @return query实例
*/
public Query whereIn(@NotNull final String propertyName,
@NotNull final List<ParameterExpression> values) {
In in = criteriaBuilder.in(from.get(propertyName));
values.forEach(in::value);
this.predicates.add(in);
return this;
}
示例3: whereValueIn
import javax.persistence.criteria.CriteriaBuilder.In; //导入依赖的package包/类
/**
* 包含
*
* @param propertyName 属性名称
* @param values 参数值集合
* @return query实例
*/
public Query whereValueIn(@NotNull final String propertyName,
@NotNull final List<Object> values) {
In in = criteriaBuilder.in(from.get(propertyName));
values.stream()
.map(this::makeParameter)
.collect(Collectors.toList())
.forEach(in::value);
this.predicates.add(in);
return this;
}
示例4: whereNotIn
import javax.persistence.criteria.CriteriaBuilder.In; //导入依赖的package包/类
/**
* 不包含
*
* @param propertyName 属性名称
* @param values 参数集合
*/
public Query whereNotIn(@NotNull final String propertyName,
@NotNull final List<ParameterExpression> values) {
In in = criteriaBuilder.in(from.get(propertyName));
values.forEach(in::value);
this.predicates.add(criteriaBuilder.not(in));
return this;
}
示例5: whereValueNotIn
import javax.persistence.criteria.CriteriaBuilder.In; //导入依赖的package包/类
/**
* 不包含
*
* @param propertyName 属性名称
* @param values 参数集合
*/
public Query whereValueNotIn(@NotNull final String propertyName,
@NotNull final List<Object> values) {
In in = criteriaBuilder.in(from.get(propertyName));
values.stream()
.map(this::makeParameter)
.collect(Collectors.toList())
.forEach(in::value);
this.predicates.add(criteriaBuilder.not(in));
return this;
}
示例6: whereIn
import javax.persistence.criteria.CriteriaBuilder.In; //导入依赖的package包/类
/**
* 包含
*
* @param propertyName 属性名称
* @param values 参数集合
*/
public Query whereIn(@NotNull final String propertyName, @NotNull final List<ParameterExpression> values) {
In in = criteriaBuilder.in(from.get(propertyName));
values.stream().forEach(in::value);
this.predicates.add(in);
return this;
}
示例7: whereValueIn
import javax.persistence.criteria.CriteriaBuilder.In; //导入依赖的package包/类
/**
* 包含
*
* @param propertyName 属性名称
* @param values 参数值集合
*/
public Query whereValueIn(@NotNull final String propertyName, @NotNull final List<Object> values) {
In in = criteriaBuilder.in(from.get(propertyName));
values.stream()
.map(this::makeParameter)
.collect(Collectors.toList())
.stream()
.forEach(in::value);
this.predicates.add(in);
return this;
}
示例8: whereNotIn
import javax.persistence.criteria.CriteriaBuilder.In; //导入依赖的package包/类
/**
* 不包含
*
* @param propertyName 属性名称
* @param values 参数集合
*/
public Query whereNotIn(@NotNull final String propertyName, @NotNull final List<ParameterExpression> values) {
In in = criteriaBuilder.in(from.get(propertyName));
values.stream().forEach(in::value);
this.predicates.add(criteriaBuilder.not(in));
return this;
}
示例9: whereValueNotIn
import javax.persistence.criteria.CriteriaBuilder.In; //导入依赖的package包/类
/**
* 不包含
*
* @param propertyName 属性名称
* @param values 参数集合
*/
public Query whereValueNotIn(@NotNull final String propertyName, @NotNull final List<Object> values) {
In in = criteriaBuilder.in(from.get(propertyName));
values.stream()
.map(this::makeParameter)
.collect(Collectors.toList())
.stream()
.forEach(in::value);
this.predicates.add(criteriaBuilder.not(in));
return this;
}
示例10: valueIn
import javax.persistence.criteria.CriteriaBuilder.In; //导入依赖的package包/类
protected <X> Specification<ENTITY> valueIn(SingularAttribute<? super ENTITY, X> field, final Collection<X>
values) {
return (root, query, builder) -> {
In<X> in = builder.in(root.get(field));
for (X value : values) {
in = in.value(value);
}
return in;
};
}
示例11: findListByPropertyInList
import javax.persistence.criteria.CriteriaBuilder.In; //导入依赖的package包/类
@Override
public final List<T> findListByPropertyInList(final SingularAttribute<T, ? extends Object> property, final Object[] values) {
final CriteriaQuery<T> criteriaQuery = criteriaBuilder.createQuery(getPersistentClass());
final Root<T> root = criteriaQuery.from(getPersistentClass());
criteriaQuery.select(root);
final In<Object> in = criteriaBuilder.in((Path<Object>) root.get(property));
for (final Object object : values) {
in.value(object);
}
criteriaQuery.where(in);
final TypedQuery<T> typedQuery = getEntityManager().createQuery(criteriaQuery);
addCacheHints(typedQuery, "findListByPropertyInList");
return typedQuery.getResultList();
}
示例12: findBy
import javax.persistence.criteria.CriteriaBuilder.In; //导入依赖的package包/类
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
public PageDto<ApplicationDto> findBy(final String userId,
final String name, final Date startDate, final Date endDate,
final ApplicationType typeGroup, final List<UserRole> roles,
final Boolean auditingStatu, PageSize pageSize, SortDto sortDto) {
if (pageSize == null) {
pageSize = new PageSize();
}
Page<Application> applications = applicationRepository.findAll(
new Specification<Application>() {
@Override
public Predicate toPredicate(Root<Application> root,
CriteriaQuery<?> query, CriteriaBuilder cb) {
List<Predicate> pres = new ArrayList<Predicate>();
if (!StringUtils.isBlank(userId)) {
pres.add(cb.equal(root.get("addUser")
.as(User.class), new User(userId)));
}
if (!StringUtils.isBlank(name)) {
pres.add(cb.like(root.get("name").as(String.class),
name));
}
// 没办法。Mysql不支持bit查询
pres.add(cb.equal(
root.get("auditingStatu").as(Integer.class),
auditingStatu ? 1 : 0));
if (startDate != null) {
pres.add(cb.greaterThanOrEqualTo(root
.get("addDate").as(Date.class), startDate));
}
if (endDate != null) {
pres.add(cb.lessThanOrEqualTo(root.get("addDate")
.as(Date.class), endDate));
}
if (typeGroup != null) {
pres.add(cb.equal(
root.get("typeGroup").as(
ApplicationType.class), typeGroup));
}
if (roles != null && !roles.isEmpty()) {
In<UserRole> in = cb.in(root.get("role").as(
UserRole.class));
for (UserRole role : roles) {
in.value(role);
}
pres.add(in);
}
Predicate[] p = new Predicate[pres.size()];
return cb.and(pres.toArray(p));
}
}, new PageRequest(pageSize.getPage() - 1, pageSize.getLimit(),
SortUtils.covertSortDto(sortDto)));
return applicationCovert.covertToDto(applications);
}