本文整理汇总了Java中org.hibernate.criterion.Property类的典型用法代码示例。如果您正苦于以下问题:Java Property类的具体用法?Java Property怎么用?Java Property使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Property类属于org.hibernate.criterion包,在下文中一共展示了Property类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLast
import org.hibernate.criterion.Property; //导入依赖的package包/类
@Override
public QuotePE getLast(String sigle) {
Session session = getSession();
DetachedCriteria maxDate = DetachedCriteria.forClass(QuotePE.class);
maxDate.add(Restrictions.eq("symbol", sigle));
maxDate.setProjection(Projections.max("creationDateTime"));
Criteria criteria = session.createCriteria(QuotePE.class);
criteria.add(Restrictions.eq("symbol", sigle));
criteria.add(Property.forName("creationDateTime").eq(maxDate));
QuotePE pe = (QuotePE) criteria.uniqueResult();
session.close();
return pe;
}
示例2: loadMessageTemplates
import org.hibernate.criterion.Property; //导入依赖的package包/类
public void loadMessageTemplates(Page<MessageTemplate> page,Criteria criteria,String type){
IUser user=ContextHolder.getLoginUser();
if(user==null){
throw new RuntimeException("Please login first!");
}
String companyId=user.getCompanyId();
if(StringUtils.isNotEmpty(getFixedCompanyId())){
companyId=getFixedCompanyId();
}
DetachedCriteria dc=this.buildDetachedCriteria(criteria, MessageTemplate.class);
if(StringUtils.isNotEmpty(type)){
dc.add(Property.forName("type").eq(type));
}
Property p=Property.forName("companyId");
dc.add(p.eq(companyId));
this.pagingQuery(page, dc);
}
示例3: afterConfigurationBuilt
import org.hibernate.criterion.Property; //导入依赖的package包/类
public void afterConfigurationBuilt(Mappings mappings, Dialect dialect) {
super.afterConfigurationBuilt( mappings, dialect );
// Oracle and Postgres do not have year() functions, so we need to
// redefine the 'User.person.yob' formula
//
// consider temporary until we add the capability to define
// mapping foprmulas which can use dialect-registered functions...
PersistentClass user = mappings.getClass( User.class.getName() );
org.hibernate.mapping.Property personProperty = user.getProperty( "person" );
Component component = ( Component ) personProperty.getValue();
Formula f = ( Formula ) component.getProperty( "yob" ).getValue().getColumnIterator().next();
SQLFunction yearFunction = ( SQLFunction ) dialect.getFunctions().get( "year" );
if ( yearFunction == null ) {
// the dialect not know to support a year() function, so rely on the
// ANSI SQL extract function
f.setFormula( "extract( year from dob )");
}
else {
List args = new ArrayList();
args.add( "dob" );
f.setFormula( yearFunction.render( args, null ) );
}
}
示例4: testComponentFormulaQuery
import org.hibernate.criterion.Property; //导入依赖的package包/类
public void testComponentFormulaQuery() {
Session s = openSession();
Transaction t = s.beginTransaction();
s.createQuery("from User u where u.person.yob = 1999").list();
s.createCriteria(User.class)
.add( Property.forName("person.yob").between( new Integer(1999), new Integer(2002) ) )
.list();
if ( getDialect().supportsRowValueConstructorSyntax() ) {
s.createQuery("from User u where u.person = ('gavin', :dob, 'Peachtree Rd', 'Karbarook Ave', 1974, 'Peachtree Rd')")
.setDate("dob", new Date("March 25, 1974")).list();
s.createQuery("from User where person = ('gavin', :dob, 'Peachtree Rd', 'Karbarook Ave', 1974, 'Peachtree Rd')")
.setDate("dob", new Date("March 25, 1974")).list();
}
t.commit();
s.close();
}
示例5: listResourcesToHarvest
import org.hibernate.criterion.Property; //导入依赖的package包/类
@Override
public List<Resource> listResourcesToHarvest(Integer limit, DateTime now, String fetch) {
Criteria criteria = getSession().createCriteria(type);
criteria.add(Restrictions.isNotNull("resourceType"));
criteria.add(Restrictions.in("status", Arrays.asList(new BatchStatus[] {BatchStatus.COMPLETED, BatchStatus.FAILED,BatchStatus.ABANDONED, BatchStatus.STOPPED})));
criteria.add(Restrictions.eq("scheduled", Boolean.TRUE));
criteria.add(Restrictions.disjunction().add(Restrictions.lt("nextAvailableDate", now)).add(Restrictions.isNull("nextAvailableDate")));
if (limit != null) {
criteria.setMaxResults(limit);
}
enableProfilePreQuery(criteria, fetch);
criteria.addOrder( Property.forName("nextAvailableDate").asc() );
List<Resource> result = (List<Resource>) criteria.list();
for(Resource t : result) {
enableProfilePostQuery(t, fetch);
}
return result;
}
示例6: getAttributeOrderCriteria
import org.hibernate.criterion.Property; //导入依赖的package包/类
private DetachedCriteria getAttributeOrderCriteria(String template, DetachedCriteria ciCrit, DetachedCriteria ci2Crit,
OrderInfo info) {
if (info.getAttrType().equals("complex")) {
return(getComplexAttributeOrderCriteria2(template, ciCrit, ci2Crit, info));
}
DetachedCriteria crit = DetachedCriteria.forClass(BasicAttribute.class);
DetachedCriteria ciIdProjection = ciCrit.setProjection(Projections.property("longId"));
crit.add(Property.forName("ownerId").in(ciIdProjection));
crit.add(Expression.eq("alias", info.getAttrAlias()));
if (info.isDescenden()) {
crit.addOrder(Order.desc(info.getAttrType()));
} else {
crit.addOrder(Order.asc(info.getAttrType()));
}
return(crit);
}
示例7: getComplexAttributeOrderCriteria
import org.hibernate.criterion.Property; //导入依赖的package包/类
private DetachedCriteria getComplexAttributeOrderCriteria(String template, DetachedCriteria ciCrit,
OrderInfo info) {
DetachedCriteria crit = DetachedCriteria.forClass(BasicAttribute.class);
DetachedCriteria ciIdProjection = ciCrit.setProjection(Projections.property("longId"));
crit.add(Property.forName("ownerId").in(ciIdProjection));
crit.add(Expression.eq("alias", info.getAttrAlias()));
//crit.add(Expression.isNotEmpty("valueAsLong"));
ICi ci = this.msvc.findCi(new Path(template));
IAttribute attr = ci.getAttributeDefinitionWithAlias(info.getAttrAlias());
IType type = attr.getValueType();
String targetTemplate = type.getAlias();
DetachedCriteria refCrit = DetachedCriteria.forClass(ConfigurationItem.class);
refCrit.add(Property.forName("longId").in(crit.setProjection(Projections.property("valueAsLong"))));
DetachedCriteria refCiCrit = DetachedCriteria.forClass(ConfigurationItem.class);
refCiCrit.add(Property.forName("longId").in(refCrit.setProjection(Projections.property("targetId"))));
return(getDisplayNameOrder(targetTemplate, refCiCrit, info));
}
示例8: getBackComplexAttributeOrder
import org.hibernate.criterion.Property; //导入依赖的package包/类
private DetachedCriteria getBackComplexAttributeOrder(List<Long> attrOwnerId, DetachedCriteria ci2Crit,
OrderInfo info) {
DetachedCriteria targetCrit = DetachedCriteria.forClass(ConfigurationItem.class);
targetCrit.add(Property.forName("longId").in(attrOwnerId));
DetachedCriteria refCrit = DetachedCriteria.forClass(ConfigurationItem.class);
refCrit.add(Property.forName("targetId").in(targetCrit.setProjection(Projections.property("longId"))));
DetachedCriteria attrCrit = DetachedCriteria.forClass(BasicAttribute.class);
attrCrit.add(Property.forName("valueAsLong").in(refCrit.setProjection(Projections.property("longId"))));
attrCrit.add(Property.forName("ownerId").in(ci2Crit.setProjection(Projections.property("longId"))));
attrCrit.add(Expression.eq("alias", info.getAttrAlias()));
attrCrit.addOrder(Order.desc("longId"));
return(attrCrit);
}
示例9: getCriteria
import org.hibernate.criterion.Property; //导入依赖的package包/类
@Override
public DetachedCriteria getCriteria() {
DetachedCriteria crit = getObjectCriteria(); //DetachedCriteria.forClass(ConfigurationItem.class);
if (getTargetIds() != null) {
crit.add(Property.forName(getRelationTargetProperty()).in(targetIds));
} else {
DetachedCriteria targetCrit = target.setProjection(Projections.property(getTargetProjection()));
crit.add(Property.forName(getRelationTargetProperty()).in(targetCrit));
}
if (getSourceIds() != null) {
crit.add(Property.forName(getRelationSourceProperty()).in(sourceIds));
} else {
DetachedCriteria sourceCrit = source.setProjection(Projections.property(getSourceProjection()));
crit.add(Property.forName(getRelationSourceProperty()).in(sourceCrit));
}
return(crit);
}
示例10: getCriteria
import org.hibernate.criterion.Property; //导入依赖的package包/类
@Override
public DetachedCriteria getCriteria() {
DetachedCriteria crit = getParent().getCriteria();
Junction junction = null;
if (disjunction) {
junction = Restrictions.disjunction();
} else {
junction = Restrictions.conjunction();
}
for (Iterator iter = attributeExpressions.iterator(); iter.hasNext();) {
AttributeExpression aExpr = (AttributeExpression) iter.next();
DetachedCriteria attrCriteria = aExpr.getCriteria();
junction.add(Property.forName("longId").in(attrCriteria.setProjection(Projections.property("ownerId"))));
}
crit.add(junction);
return(crit);
}
示例11: getCriteria
import org.hibernate.criterion.Property; //导入依赖的package包/类
@Override
protected DetachedCriteria getCriteria() {
// Select Target/Source attribute id.
DetachedCriteria attrTarget = DetachedCriteria.forClass(BasicAttribute.class);
attrTarget.add(Expression.eq("valueAsLong", targetId));
attrTarget.add(Expression.eq("alias", "target"));
DetachedCriteria relOwnerCrit = attrTarget.setProjection(Projections.property("ownerId"));
DetachedCriteria relCi = DetachedCriteria.forClass(ConfigurationItem.class);
relCi.add(Property.forName("longId").in(relOwnerCrit));
relCi.add(Expression.eq("derivedFromId", referenceTemplateId));
DetachedCriteria targetOwnerCrit = relCi.setProjection(Projections.property("longId"));
DetachedCriteria attrSource = DetachedCriteria.forClass(BasicAttribute.class);
attrSource.add(Expression.eq("alias", "source"));
attrSource.add(Property.forName("ownerId").in(targetOwnerCrit));
DetachedCriteria sourceIdCrit = attrSource.setProjection(Projections.property("valueAsLong"));
DetachedCriteria sourceCi = DetachedCriteria.forClass(ConfigurationItem.class);
sourceCi.add(Property.forName("longId").in(sourceIdCrit));
return(sourceCi);
}
示例12: prepareCriteria
import org.hibernate.criterion.Property; //导入依赖的package包/类
private Criteria prepareCriteria(String user, String act, Date fechaIni, Date fechaFin){
Criteria criteria = this.getCurrentSession().createCriteria(Log.class);
if(fechaIni != null)
criteria.add(Property.forName("stamp").ge(fechaIni));
if(fechaFin != null)
criteria.add(Property.forName("stamp").le(fechaFin));
if(user != null && !user.isEmpty())
criteria
.createCriteria("user")
.add(Property.forName("pid").eq(user));
if(act != null && !act.isEmpty())
criteria.add(Property.forName("action").eq(act));
return criteria;
}
示例13: findProtocolById
import org.hibernate.criterion.Property; //导入依赖的package包/类
public Protocol findProtocolById(String protocolId) throws Exception {
if (!springSecurityAclService.currentUserHasReadPermission(Long.valueOf(protocolId), SecureClassesEnum.PROTOCOL.getClazz()) &&
!springSecurityAclService.currentUserHasWritePermission(Long.valueOf(protocolId), SecureClassesEnum.PROTOCOL.getClazz())) {
new NoAccessException("User has no access to the protocol " + protocolId);
}
Protocol protocol = null;
CaNanoLabApplicationService appService = (CaNanoLabApplicationService) ApplicationServiceProvider.getApplicationService();
DetachedCriteria crit = DetachedCriteria.forClass(Protocol.class).add(Property.forName("id").eq(new Long(protocolId)));
crit.setFetchMode("file", FetchMode.JOIN);
crit.setFetchMode("file.keywordCollection", FetchMode.JOIN);
List result = appService.query(crit);
if (!result.isEmpty()) {
protocol = (Protocol) result.get(0);
}
return protocol;
}
示例14: findPublicationById
import org.hibernate.criterion.Property; //导入依赖的package包/类
public Publication findPublicationById(String publicationId) throws Exception
{
Long pubId = Long.valueOf(publicationId);
if (!springSecurityAclService.currentUserHasReadPermission(pubId, SecureClassesEnum.PUBLICATION.getClazz()) &&
!springSecurityAclService.currentUserHasWritePermission(pubId, SecureClassesEnum.PUBLICATION.getClazz())) {
throw new NoAccessException("User has no access to the publication " + publicationId);
}
CaNanoLabApplicationService appService = (CaNanoLabApplicationService) ApplicationServiceProvider.getApplicationService();
DetachedCriteria crit = DetachedCriteria.forClass(Publication.class).add(Property.forName("id").eq(pubId));
crit.setFetchMode("authorCollection", FetchMode.JOIN);
crit.setFetchMode("keywordCollection", FetchMode.JOIN);
crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
List result = appService.query(crit);
Publication publication = null;
if (!result.isEmpty()) {
publication = (Publication) result.get(0);
}
return publication;
}
示例15: findPublicationByKey
import org.hibernate.criterion.Property; //导入依赖的package包/类
public Publication findPublicationByKey(String keyName, Object keyValue)
throws Exception {
CaNanoLabApplicationService appService = (CaNanoLabApplicationService) ApplicationServiceProvider
.getApplicationService();
DetachedCriteria crit = DetachedCriteria.forClass(Publication.class)
.add(Property.forName(keyName).eq(keyValue));
crit.setFetchMode("authorCollection", FetchMode.JOIN);
crit.setFetchMode("keywordCollection", FetchMode.JOIN);
crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
List result = appService.query(crit);
Publication publication = null;
if (!result.isEmpty()) {
publication = (Publication) result.get(0);
if (springSecurityAclService.currentUserHasReadPermission(publication.getId(), SecureClassesEnum.PUBLICATION.getClazz()) ||
springSecurityAclService.currentUserHasWritePermission(publication.getId(), SecureClassesEnum.PUBLICATION.getClazz())) {
return publication;
} else {
throw new NoAccessException();
}
}
return publication;
}