本文整理了Java中org.hibernate.Criteria.addOrder()
方法的一些代码示例,展示了Criteria.addOrder()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Criteria.addOrder()
方法的具体详情如下:
包路径:org.hibernate.Criteria
类名称:Criteria
方法名:addOrder
[英]Add an Order to the result set.
[中]将订单添加到结果集中。
代码示例来源:origin: stackoverflow.com
Criteria c = session.createCriteria(Cat.class);
c.createAlias("mother.kind", "motherKind");
c.addOrder(Order.asc("motherKind.value"));
return c.list();
代码示例来源:origin: gocd/gocd
public EnvironmentVariables load(final Long entityId, final EnvironmentVariableType type) {
List<EnvironmentVariable> result = (List<EnvironmentVariable>) transactionTemplate.execute((TransactionCallback) transactionStatus -> {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(EnvironmentVariable.class).add(Restrictions.eq("entityId", entityId)).add(
Restrictions.eq("entityType", type.toString())).addOrder(Order.asc("id"));
criteria.setCacheable(true);
return criteria.list();
});
return new EnvironmentVariables(result);
}
代码示例来源:origin: hibernate/hibernate-orm
protected Criteria getCriteria(Session s) {
// should use RootEntityTransformer by default
return s.createCriteria( Student.class )
.addOrder( Order.asc( "studentNumber" ) );
}
};
代码示例来源:origin: kaaproject/kaa
@Override
public EndpointProfileSchema findLatestByAppId(String appId) {
EndpointProfileSchema latestSchema = null;
LOG.debug("Searching latest profile schema by application id [{}] ", appId);
if (isNotBlank(appId)) {
Criteria criteria = getCriteria().createAlias(APPLICATION_PROPERTY, APPLICATION_ALIAS)
.add(Restrictions.eq(APPLICATION_REFERENCE, Long.valueOf(appId)))
.addOrder(Order.desc(VERSION_PROPERTY)).setMaxResults(FIRST);
latestSchema = findOneByCriteria(criteria);
}
if (LOG.isTraceEnabled()) {
LOG.trace("[{}] Search result: {}.", appId, latestSchema);
} else {
LOG.debug("[{}] Search result: {}.", appId, latestSchema != null);
}
return latestSchema;
}
代码示例来源:origin: hibernate/hibernate-orm
cr.setFetchMode( "topGlarchez", FetchMode.SELECT );
List result = cr
.addOrder( Order.asc("name") )
.list();
assertTrue( result.size()==1 );
b = (Baz) result.get(0);
代码示例来源:origin: hibernate/hibernate-orm
.add( Property.forName("name").between("bar", "foo") )
.addOrder( Order.desc("name") )
.list();
p = (Parent) parents.get(0);
q = (Parent) parents.get(1);
代码示例来源:origin: kaaproject/kaa
@Override
public List<CtlSchema> findAllByMetaInfoId(String metaInfoId) {
LOG.debug("Searching available version of ctl schema by meta info id [{}]", metaInfoId);
Criteria criteria = getCriteria()
.createAlias(CTL_SCHEMA_META_INFO_PROPERTY, CTL_SCHEMA_META_INFO_ALIAS)
.add(Restrictions.eq(CTL_SCHEMA_META_INFO_ALIAS_ID, Long.valueOf(metaInfoId)))
.addOrder(Order.asc(CTL_SCHEMA_VERSION));
List<CtlSchema> schemas = findListByCriteria(criteria);
if (LOG.isTraceEnabled()) {
LOG.trace("Search result: [{}].", Arrays.toString(schemas.toArray()));
} else {
LOG.debug("Search result: [{}].", schemas.size());
}
return schemas;
}
代码示例来源:origin: kaaproject/kaa
@Override
public LogSchema findLatestLogSchemaByAppId(String applicationId) {
LOG.debug("Searching latest log schema by application id [{}]", applicationId);
LogSchema logSchema = null;
if (isNotBlank(applicationId)) {
Criteria criteria = getCriteria();
criteria.createAlias(APPLICATION_PROPERTY, APPLICATION_ALIAS);
Criterion criterion = Restrictions.eq(APPLICATION_REFERENCE, Long.valueOf(applicationId));
logSchema = (LogSchema) criteria.add(criterion).addOrder(Order.desc(VERSION_PROPERTY))
.setMaxResults(FIRST).uniqueResult();
}
if (LOG.isTraceEnabled()) {
LOG.trace("[{}] Search result: {}.", applicationId, logSchema);
} else {
LOG.debug("[{}] Search result: {}.", applicationId, logSchema != null);
}
return logSchema;
}
代码示例来源:origin: hibernate/hibernate-orm
.addOrder( Order.asc( "displayCode" ) )
.list();
.addOrder( Order.asc( "displayCodeAsInteger" ) )
.list();
代码示例来源:origin: hibernate/hibernate-orm
protected Criteria getCriteria(Session s) {
// should use RootEntityTransformer by default
return s.createCriteria( CourseMeeting.class )
.addOrder( Order.asc( "id.day" ) );
}
};
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.db.ConceptDAO#getPrevConcept(org.openmrs.Concept)
*/
@Override
@SuppressWarnings("unchecked")
public Concept getPrevConcept(Concept c) {
Integer i = c.getConceptId();
List<Concept> concepts = sessionFactory.getCurrentSession().createCriteria(Concept.class).add(
Restrictions.lt("conceptId", i)).addOrder(Order.desc("conceptId")).setFetchSize(1).list();
if (concepts.isEmpty()) {
return null;
}
return concepts.get(0);
}
代码示例来源:origin: gocd/gocd
public ServerBackup lastBackup() {
List results = (List) getHibernateTemplate().execute((HibernateCallback) session -> {
Criteria criteria = session.createCriteria(ServerBackup.class);
criteria.setMaxResults(1);
criteria.addOrder(Order.desc("id"));
return criteria.list();
});
return results.isEmpty() ? null : (ServerBackup) results.get(0);
}
代码示例来源:origin: kaaproject/kaa
CTL_SCHEMA_META_INFO_PROPERTY,
CTL_SCHEMA_META_INFO_ALIAS)
.add(Restrictions.and(
Restrictions.eq(CTL_SCHEMA_META_INFO_ALIAS_FQN, fqn),
tenantId != null
? Restrictions.eq(
CTL_SCHEMA_META_INFO_ALIAS_TENANT_ID,
Long.valueOf(tenantId))
: Restrictions.isNull(CTL_SCHEMA_META_INFO_ALIAS_TENANT_ID),
applicationId != null
? Restrictions.eq(
CTL_SCHEMA_META_INFO_ALIAS_APPLICATION_ID,
Long.valueOf(applicationId))
: Restrictions.isNull(CTL_SCHEMA_META_INFO_ALIAS_APPLICATION_ID))
).addOrder(Order.asc(CTL_SCHEMA_VERSION));
代码示例来源:origin: kaaproject/kaa
@Override
public ConfigurationSchema findLatestByApplicationId(String appId) {
ConfigurationSchema latestSchema = null;
LOG.debug("Searching latest configuration schema by application id [{}] ", appId);
if (isNotBlank(appId)) {
Criteria criteria = getCriteria().createAlias(APPLICATION_PROPERTY, APPLICATION_ALIAS)
.add(Restrictions.eq(APPLICATION_REFERENCE, Long.valueOf(appId)))
.addOrder(Order.desc(VERSION_PROPERTY))
.setMaxResults(FIRST);
latestSchema = findOneByCriteria(criteria);
}
if (LOG.isTraceEnabled()) {
LOG.trace("[{}] Search result: {}.", appId, latestSchema);
} else {
LOG.debug("[{}] Search result: {}.", appId, latestSchema != null);
}
return latestSchema;
}
代码示例来源:origin: hibernate/hibernate-orm
criteria.addOrder( org.hibernate.criterion.Order.asc( "name" ).nulls( NullPrecedence.LAST ) );
Iterator<Zoo> iterator = (Iterator<Zoo>) criteria.list().iterator();
Assert.assertEquals( zoo2.getName(), iterator.next().getName() );
Assert.assertNull( iterator.next().getName() );
代码示例来源:origin: hibernate/hibernate-orm
protected Criteria getCriteria(Session s) {
// should use RootEntityTransformer by default
return s.createCriteria( Student.class, "s" )
.createAlias( "s.addresses", "a", Criteria.LEFT_JOIN )
.addOrder( Order.asc( "s.studentNumber") );
}
};
代码示例来源:origin: hibernate/hibernate-orm
.createCriteria("moreChildren")
.createCriteria("friends")
.addOrder( Order.desc("name") )
.list();
.addOrder( Order.desc("name") )
.list();
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@Override
public List<AssignedProductOptionDTO> findAssignedProductOptionsByProductId(Long productId) {
Session session = em.unwrap(Session.class);
Criteria criteria = session.createCriteria(SkuProductOptionValueXrefImpl.class);
List dtoList = criteria
.createAlias("sku", "sku")
.createAlias("sku.product", "product")
.createAlias("productOptionValue", "productOptionValue")
.createAlias("productOptionValue.productOption", "productOption")
.setProjection(Projections.distinct(
Projections.projectionList()
.add(Projections.property("product.id"), "productId")
.add(Projections.property("productOption.attributeName"), "productOptionAttrName")
.add(Projections.property("productOptionValue"), "productOptionValue")
.add(Projections.property("sku"), "sku")
)
).setResultTransformer(Transformers.aliasToBean(AssignedProductOptionDTO.class))
.add(Restrictions.eq("product.id", productId))
.addOrder(Order.asc("productOption.attributeName")).list();
List<AssignedProductOptionDTO> results = new ArrayList<>();
for (Object o : dtoList) {
AssignedProductOptionDTO dto = (AssignedProductOptionDTO) o;
if (dto.getSku().isActive()) {
results.add(dto);
}
}
return results;
}
代码示例来源:origin: kaaproject/kaa
@Override
public NotificationSchema findLatestNotificationSchemaByAppId(
String appId, NotificationTypeDto type) {
LOG.debug("Searching latest notification schema by application id [{}] type [{}]", appId, type);
NotificationSchema latestSchema = null;
if (isNotBlank(appId)) {
Criteria criteria = getCriteria().add(Restrictions.and(
Restrictions.eq(APPLICATION_REFERENCE, Long.valueOf(appId)),
Restrictions.eq(NOTIFICATION_SCHEMA_TYPE_PROPERTY, type)
)).addOrder(Order.desc(VERSION_PROPERTY)).setMaxResults(FIRST);
latestSchema = findOneByCriteria(criteria);
}
if (LOG.isTraceEnabled()) {
LOG.trace("[{},{}] Search result: {}.", appId, type, latestSchema);
} else {
LOG.debug("[{},{}] Search result: {}.", appId, type, latestSchema != null);
}
return latestSchema;
}
}
代码示例来源:origin: hibernate/hibernate-orm
.add( Property.forName( "course" ), "course" )
.addOrder( Order.asc( "studentNumber") )
.list();
t.commit();
s.close();
内容来源于网络,如有侵权,请联系作者删除!