public ConstantsCache<Resolution> get() { final List<ResolutionDTO> resolutionList = dbConnectionManager.executeQuery(dbConnection -> dbConnection.newSqlQuery().from(RESOLUTION) .orderBy(RESOLUTION.sequence.asc()).list(RESOLUTION)); final ImmutableMap.Builder<String, Resolution> builder = ImmutableMap.builder(); resolutionList.stream().map(issueConstantFactory::createResolution).forEach(r -> builder.put(r.getId(), r)); return new ConstantsCache<>(builder.build()); } }
public ConstantsCache<Priority> get() { final List<PriorityDTO> priorityList = dbConnectionManager.executeQuery(dbConnection -> dbConnection.newSqlQuery().from(PRIORITY) .orderBy(PRIORITY.sequence.asc()).list(PRIORITY)); final ImmutableMap.Builder<String, Priority> builder = ImmutableMap.builder(); priorityList.stream().map(issueConstantFactory::createPriority).forEach(p -> builder.put(p.getId(), p)); return new ConstantsCache<>(builder.build()); } }
public ConstantsCache<Status> get() { final List<StatusDTO> statusList = dbConnectionManager.executeQuery(dbConnection -> dbConnection.newSqlQuery().from(STATUS) .orderBy(STATUS.sequence.asc()).list(STATUS)); final ImmutableMap.Builder<String, Status> builder = ImmutableMap.builder(); statusList.stream().map(issueConstantFactory::createStatus).forEach(r -> builder.put(r.getId(), r)); return new ConstantsCache<>(builder.build()); } }
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); }
@Test public void OrderExpressionInFunctionalWay() { cat.bodyWeight.asc(); cat.bodyWeight.add(kitten.bodyWeight).asc(); }
public List<MirrorPropertyEntity> findByParentProperty(MirrorPropertyEntity parentProperty) { JPAQuery query = new JPAQuery(entityManager); QMirrorPropertyEntity mirrorProperty = new QMirrorPropertyEntity("mpro"); List<MirrorPropertyEntity> list = query.from(mirrorProperty) .where(mirrorProperty.parentProperty.eq(parentProperty)) .orderBy(mirrorProperty.deep.asc()) .list(mirrorProperty); return list; }
/** * 查询元数据对象下面,所以的镜像 * 包含关联属性,结构化属性 * @param rootMObject * @return */ public List<MirrorPropertyEntity> findByRootMObject(MObjectEntity rootMObject) { JPAQuery query = new JPAQuery(entityManager); QMirrorPropertyEntity mirrorProperty = new QMirrorPropertyEntity("mpro"); List<MirrorPropertyEntity> list = query.from(mirrorProperty) .where(mirrorProperty.rootMObject.eq(rootMObject)) .orderBy(mirrorProperty.deep.asc()) .list(mirrorProperty); return list; }
private List<QueuedEmailDTO> selectQueuedEmailForUpdate(final int limit) { return querydslSupport.execute((connection, configuration) -> { QEmailQueue qEmailQueue = QEmailQueue.emailQueue; return new SQLQuery(connection, configuration) .from(qEmailQueue) .orderBy(qEmailQueue.timestamp_.asc(), qEmailQueue.queuedEmailId.asc()) .limit(limit) .forUpdate() .list(Projections.fields(QueuedEmailDTO.class, qEmailQueue.queuedEmailId, qEmailQueue.storedEmailId)); }); }
public List<MTemplateEntity> findTemplateAll(MObjectEntity belongMObject) { QMTemplateEntity obj = QMTemplateEntity.mTemplateEntity; JPAQuery query = new JPAQuery(entityManager); List<MTemplateEntity> templateList = query.from(obj) .where(obj.belongMObject.eq(belongMObject) ) .orderBy(obj.isSystem.desc()) .orderBy(obj.templateType.asc()) .orderBy(obj.sort.asc()) .list(obj); return templateList; } }
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 @NoEclipseLink // EclipseLink uses a left join for cat.mate public void Case5() { assertEquals(ImmutableList.of(0, 1, 1, 1), query().from(cat).orderBy(cat.id.asc()) .list(cat.mate.when(savedCats.get(0)).then(0).otherwise(1))); }
@Test @Ignore public void Type() { assertEquals(Arrays.asList("C","C","C","C","C","C","A"), query().from(animal).orderBy(animal.id.asc()).list(JPAExpressions.type(animal))); }
@Test @NoOpenJPA public void Type_Order() { assertEquals(Arrays.asList(10,1,2,3,4,5,6), query().from(animal).orderBy(JPAExpressions.type(animal).asc(), animal.id.asc()) .list(animal.id)); } }
public List<MirrorPropertyEntity> findByBelongMObjectAndNameAndIsEnable(MObjectEntity rootMObject, 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(rootMObject) .and(mirrorProperty.belongMObject.eq(belongMObject)) .and(mirrorProperty.name.eq(name).or(mirrorProperty.secondName.eq(name))) ) .orderBy(mirrorProperty.deep.asc()) .list(mirrorProperty); return list; }
@Test @NoBatooJPA public void Case_Long() { assertEquals(ImmutableList.of(1L, 2L, 2L, 2L, 2L, 2L), query().from(cat).orderBy(cat.id.asc()) .list(cat.name.when("Bob123").then(1L).otherwise(2L))); }
@Test public void Order() { NumberPath<Double> weight = new NumberPath<Double>(Double.class, "weight"); query().from(cat).orderBy(weight.asc()).list(cat.bodyWeight.as(weight)); }
@Test @NoBatooJPA public void Case() { assertEquals(ImmutableList.of(1, 2, 2, 2, 2, 2), query().from(cat).orderBy(cat.id.asc()) .list(cat.name.when("Bob123").then(1).otherwise(2))); }
@Test @ExcludeIn(MYSQL) // doesn't work in Eclipselink public void Case4() { NumberExpression<Float> numExpression = cat.bodyWeight.floatValue().divide(otherCat.bodyWeight.floatValue()).multiply(100); NumberExpression<Float> numExpression2 = cat.id.when(0).then(0.0F).otherwise(numExpression); assertEquals(ImmutableList.of(200, 150, 133, 125, 120), query().from(cat, otherCat) .where(cat.id.eq(otherCat.id.add(1))) .orderBy(cat.id.asc(), otherCat.id.asc()) .list(numExpression2.intValue())); }
public List<MTemplateEntity> findCustomTemplates(MObjectEntity belongMObject, MTemplateTypeEnum templateType, Boolean isSystem) { QMTemplateEntity obj = QMTemplateEntity.mTemplateEntity; JPAQuery query = new JPAQuery(entityManager); List<MTemplateEntity> templateList = query.from(obj) .where(obj.isSystem.eq(isSystem) .and(obj.belongMObject.eq(belongMObject)) .and(obj.templateType.eq(templateType)) ) .orderBy(obj.isSystem.desc()) .orderBy(obj.templateType.asc()) .orderBy(obj.sort.asc()) .list(obj); return templateList; }
@Test public void Order_By_Count() { NumberPath<Long> count = Expressions.numberPath(Long.class, "c"); query().from(cat) .groupBy(cat.id) .orderBy(count.asc()) .list(cat.id, cat.id.count().as(count)); }