@Override public long doInSqlDeleteClause(SQLDeleteClause delete) { return delete.where(qAddress.customerId.eq(customer.getId()).and(qAddress.id.notIn(ids))).execute(); } });
/** * Get an intersection of this and the union of the given predicates * * @param predicates * @return */ public BooleanExpression andAnyOf(Predicate... predicates) { return and(ExpressionUtils.anyOf(predicates)); }
@Override public List<MirrorPropertyEntity> findByBelongMObjectAndControllerTypeAndIsEnable(MObjectEntity belongMObject, MControllerTypeEnum controllerTypeEnum, boolean isEnable) { JPAQuery query = new JPAQuery(entityManager); QMirrorPropertyEntity mirrorProperty = new QMirrorPropertyEntity("mpro"); List<MirrorPropertyEntity> list = query.from(mirrorProperty) .where(mirrorProperty.rootMObject.eq(belongMObject) .and(mirrorProperty.belongMObject.eq(belongMObject)) .and(mirrorProperty.controllerType.eq(controllerTypeEnum)) ) .list(mirrorProperty); return list; }
@Override public List<MirrorPropertyEntity> findByBelongMObjectAndIsEnableAndIsNullable(MObjectEntity belongMObject, boolean isEnable, boolean isNullable) { JPAQuery query = new JPAQuery(entityManager); QMirrorPropertyEntity mirrorProperty = new QMirrorPropertyEntity("mpro"); List<MirrorPropertyEntity> list = query.from(mirrorProperty) .where(mirrorProperty.belongMObject.eq(belongMObject) .and(mirrorProperty.metaProperty.isEnable.eq(isEnable)) .and(mirrorProperty.metaProperty.isNullable.eq(isNullable)) ) .list(mirrorProperty); return list; }
@Override public List<MirrorPropertyEntity> findByBelongMObjectAndIsEnable(MObjectEntity belongMObject, boolean isEnable) { JPAQuery query = new JPAQuery(entityManager); QMirrorPropertyEntity mirrorProperty = new QMirrorPropertyEntity("mpro"); List<MirrorPropertyEntity> list = query.from(mirrorProperty) .where(mirrorProperty.belongMObject.eq(belongMObject) .and(mirrorProperty.rootMObject.eq(belongMObject)) .and(mirrorProperty.deep.eq(0)) ) .list(mirrorProperty); return list; }
public List<MirrorPropertyEntity> findByBelongMObjectAndFieldNameAndIsEnable(MObjectEntity rootMObject, MObjectEntity belongMObject, String fieldName, boolean isEnable) { JPAQuery query = new JPAQuery(entityManager); QMirrorPropertyEntity mirrorProperty = new QMirrorPropertyEntity("mpro"); List<MirrorPropertyEntity> list = query.from(mirrorProperty) .where(mirrorProperty.rootMObject.eq(rootMObject) .and(mirrorProperty.belongMObject.eq(belongMObject)) .and(mirrorProperty.fieldName.eq(fieldName)) ) .list(mirrorProperty); return list; } @Override
public List<Contact> findPageByCompanyAndName(Company company, String filter, int firstrow, int maxrows) { QContact c = QContact.contact; return repository.findAll(c.company.eq(company).and(c.name. containsIgnoreCase(filter)), new PageRequest(firstrow / maxrows, maxrows) ).getContent(); }
public List<ApaVwPersonasItems> getItemsAccesiblesByPersona(String codigoAplicacion, Long personaId) { JPAQuery query = new JPAQuery(entityManager); QApaVwPersonasItems apaVWPersonasItems = QApaVwPersonasItems.apaVwPersonasItems; query.from(apaVWPersonasItems) .where(apaVWPersonasItems.personaId.eq(new BigDecimal(personaId)).and( apaVWPersonasItems.aplicacionCodigo.eq(codigoAplicacion))) .orderBy(apaVWPersonasItems.orden.asc()); return query.list(apaVWPersonasItems); }
@Override public List<MirrorPropertyEntity> findByTypeEnumAndIsEnable(MTypeEnum typeEnum, boolean isEnable) { JPAQuery query = new JPAQuery(entityManager); QMirrorPropertyEntity mirrorProperty = new QMirrorPropertyEntity("mpro"); List<MirrorPropertyEntity> list = query.from(mirrorProperty) .where(mirrorProperty.metaProperty.typeEnum.eq(typeEnum) .and(mirrorProperty.metaProperty.isEnable.eq(isEnable)) ) .list(mirrorProperty); return list; }
private List<Long> getMinusOneUserLocalePropertyIds(DbConnection dbConnection) { QOSPropertyEntry propertyEntry = QOSPropertyEntry.O_S_PROPERTY_ENTRY; QOSPropertyString propertyString = QOSPropertyString.O_S_PROPERTY_STRING; // MSSQL meet incompatible data type problem when we use equal operator (IN, EQUALS) so we have to use LIKE instead List<Long> propertyIds = dbConnection.newSqlQuery().from(propertyEntry).join(propertyString) .on(propertyEntry.id.eq(propertyString.id)) .where(propertyEntry.propertyKey.eq("jira.user.locale").and(propertyString.value.like("-1"))) .list(propertyString.id); return propertyIds; }
public List<MirrorPropertyEntity> findAllByBelongMObjectAndNameAndIsEnable(MObjectEntity belongMObject, String name, boolean isEnable) { JPAQuery query = new JPAQuery(entityManager); QMirrorPropertyEntity mirrorProperty = new QMirrorPropertyEntity("mpro"); List<MirrorPropertyEntity> list = query.from(mirrorProperty) .where( mirrorProperty.rootMObject.eq(belongMObject) .and(mirrorProperty.name.eq(name).or(mirrorProperty.secondName.eq(name))) ).orderBy(mirrorProperty.deep.asc()) .list(mirrorProperty); return list; }
@Test public void LogicalOperations_And2() { assertToString("cat is null and (kitten is null or kitten.bodyWeight > ?1)", cat.isNull().and(kitten.isNull().or(kitten.bodyWeight.gt(10)))); }
@Test public void And_Or() { //A.a.id.eq(theId).and(B.b.on.eq(false).or(B.b.id.eq(otherId))); QCat cat = QCat.cat; Predicate pred = cat.id.eq(1).and(cat.name.eq("Kitty").or(cat.name.eq("Boris"))); JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT); serializer.handle(pred); assertEquals("cat.id = ?1 and (cat.name = ?2 or cat.name = ?3)", serializer.toString()); assertEquals("cat.id = 1 && (cat.name = Kitty || cat.name = Boris)", pred.toString()); }
@Test public void And_Operation() { Predicate predicate = cat.kittens.any().name.eq("Ruth123").and(cat.kittens.any().bodyWeight.gt(10.0)); assertMatches("exists \\(select 1\n"+ "from cat.kittens as cat_kittens.*\n" + "where cat_kittens.*\\.name = \\?1\\) and exists \\(select 1\n" + "from cat.kittens as cat_kittens.*\n" + "where cat_kittens.*\\.bodyWeight > \\?2\\)", serialize(predicate)); }
@Test public void Clone() { QCat cat = QCat.cat; BooleanBuilder emptyBooleanBuilder = new BooleanBuilder(); HibernateQuery hq = new HibernateQuery().from(cat).where(cat.name.isNull().and(emptyBooleanBuilder)); HibernateQuery hq2 = hq.clone(); assertNotNull(hq2); }
@Test public void CaseBuilder() { QCat cat2 = new QCat("cat2"); NumberExpression<Integer> casex = new CaseBuilder() .when(cat.weight.isNull().and(cat.weight.isNull())).then(0) .when(cat.weight.isNull()).then(cat2.weight) .when(cat2.weight.isNull()).then(cat.weight) .otherwise(cat.weight.add(cat2.weight)); query().from(cat, cat2).orderBy(casex.asc()).list(cat.id, cat2.id); query().from(cat, cat2).orderBy(casex.desc()).list(cat.id, cat2.id); }