本文整理汇总了Java中org.hibernate.criterion.Expression类的典型用法代码示例。如果您正苦于以下问题:Java Expression类的具体用法?Java Expression怎么用?Java Expression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Expression类属于org.hibernate.criterion包,在下文中一共展示了Expression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.hibernate.criterion.Expression; //导入依赖的package包/类
@Override
public void execute() {
try{
Transaction tx = session.beginTransaction();
Criterion tmp1 = Expression.between("deadline", startDate, endDate);
Criterion tmp2 = Expression.eq("warningTypes", wtype);
Criteria crt = session.createCriteria(Warnings.class).add(Expression.and(tmp1, tmp2));
crt.createAlias("lending", "l").createAlias("l.users", "u").createAlias("warningTypes", "w");
crt.setProjection(Projections.projectionList()
.add(Projections.property("warnNo"))
.add(Projections.property("w.name"))
.add(Projections.property("wdate"))
.add(Projections.property("deadline"))
.add(Projections.property("u.userId"))
.add(Projections.property("u.lastName"))
.add(Projections.property("u.firstName"))
.add(Projections.property("l.ctlgNo"))
.add(Projections.property("l.returnDate"))
.add(Projections.property("note")));
list = crt.list();
tx.commit();
}catch (Exception e){
log.error(e);
}
}
示例2: execute
import org.hibernate.criterion.Expression; //导入依赖的package包/类
@Override
public void execute() {
try{
Transaction tx = session.beginTransaction();
Criteria crt = session.createCriteria(Users.class);
crt.add(Expression.isNotNull("blockReasons"));
crt.add(Expression.not(Expression.like("blockReasons","")));
crt.addOrder(Order.desc("blockReasons"));
if (!location.equals(" ")) {
crt.createAlias("signings", "s");
crt.add(Expression.eq("s.location", location));
crt.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
}
if (crt != null) {
list = crt.list();
}
tx.commit();
log.info("Blocked report");
}catch (Exception e){
log.error("Blocked report failed");
log.error(e);
}
}
示例3: execute
import org.hibernate.criterion.Expression; //导入依赖的package包/类
@Override
public void execute() {
try{
Transaction tx = session.beginTransaction();
Criteria crt = session.createCriteria(Users.class);
Criteria signcrt = crt.createCriteria("signings");
signcrt.add(Expression.between("signDate", start, end));
signcrt.add(Expression.or(Expression.isNull("cost"),Expression.eq("cost", 0.0)));
if (!location.equals(" ")) {
signcrt.add(Expression.eq("location", location));
}
if (crt != null) {
num = crt.list().size();
}
tx.commit();
log.info("FreeSigning report");
}catch (Exception e){
log.error("FreeSigning report failed");
log.error(e);
}
}
示例4: execute
import org.hibernate.criterion.Expression; //导入依赖的package包/类
@Override
public void execute() {
try{
Transaction tx = session.beginTransaction();
Criteria crt = session.createCriteria(Groups.class);
// if (!location.equals(" ")) {
// Criteria crt1 = crt.createCriteria("userses");
// Criteria crt2 = crt1.createCriteria("signings");
// crt2.add(Expression.eq("location", location));
// }
if (!location.equals("")) {
crt.add(Expression.like("userId", location+"%"));
}
if (crt != null) {
list = crt.list();
}
tx.commit();
log.info("Groups report");
}catch (Exception e){
log.error("Groups report failed");
log.error(e);
}
}
示例5: execute
import org.hibernate.criterion.Expression; //导入依赖的package包/类
@Override
public void execute() {
try{
Transaction tx = session.beginTransaction();
Criteria crt = session.createCriteria(Users.class);
Criteria signcrt = crt.createCriteria("signings");
signcrt.add(Expression.between("signDate", start, end));
if (!location.equals(" ")) {
signcrt.add(Expression.eq("location", location));
}
if (crt != null) {
num = crt.list().size();
}
tx.commit();
log.info("UsersNumber report");
}catch (Exception e){
log.error("UsersNumber report failed");
log.error(e);
}
}
示例6: execute
import org.hibernate.criterion.Expression; //导入依赖的package包/类
@Override
public void execute() {
try{
Transaction tx = session.beginTransaction();
Criteria crt = session.createCriteria(Users.class);
Criteria crt1 = crt.createCriteria("signings");
crt1.add(Expression.between("signDate", start,end));
crt.add(Expression.eq("groups", group));
if (!location.equals(" ")) {
crt1.add(Expression.eq("location", location));
}
if (crt != null) {
list = crt.list();
}
tx.commit();
log.info("MemberByGroup report");
}catch (Exception e){
log.error("MemberByGroup report failed");
log.error(e);
}
}
示例7: findCandidateChildren
import org.hibernate.criterion.Expression; //导入依赖的package包/类
/**
* Finds Tasks who are valid candidates to be added as children to the passed Task. This finds Tasks in the same
* groups and who are not already children or parents of the passed Task.
*
* @param task Task to find candidate children for.
* @return Set of candidate child Tasks.
*/
public Set<Task> findCandidateChildren(final Task task) {
final Set<Long> parentTasklds = task.getParentTaskIds(true);
final Set<Long> childTaskIds = task.getChildTaskIds(false);
List<Task> taskList = (List<Task>) this.getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session session) {
Criteria criteria = session.createCriteria(Task.class);
criteria.add(Expression.eq("groupName", task.getGroupName()));
criteria.add(Expression.not(Expression.eq("id", task.getId())));
if (!parentTasklds.isEmpty()) {
criteria.add(Expression.not(Expression.in("id", parentTasklds)));
}
if (!childTaskIds.isEmpty()) {
criteria.add(Expression.not(Expression.in("id", childTaskIds)));
}
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
return criteria.list();
}
});
return new HashSet<Task>(taskList);
}
示例8: testJunctionNotExpressionQBE
import org.hibernate.criterion.Expression; //导入依赖的package包/类
public void testJunctionNotExpressionQBE() throws Exception {
deleteData();
initData();
Session s = openSession();
Transaction t = s.beginTransaction();
Componentizable master = getMaster("hibernate", null, "ope%");
Criteria crit = s.createCriteria(Componentizable.class);
Example ex = Example.create(master).enableLike();
crit.add(Expression.or(Expression.not(ex), ex));
List result = crit.list();
assertNotNull(result);
assertEquals(2, result.size());
t.commit();
s.close();
}
示例9: testCriteriaCollection
import org.hibernate.criterion.Expression; //导入依赖的package包/类
public void testCriteriaCollection() throws Exception {
Session s = openSession();
Fum fum = new Fum( fumKey("fum") );
fum.setFum("a value");
fum.getMapComponent().getFummap().put("self", fum);
fum.getMapComponent().getStringmap().put("string", "a staring");
fum.getMapComponent().getStringmap().put("string2", "a notha staring");
fum.getMapComponent().setCount(1);
s.save(fum);
s.flush();
s.connection().commit();
s.close();
s = openSession();
Fum b = (Fum) s.createCriteria(Fum.class).add(
Expression.in("fum", new String[] { "a value", "no value" } )
)
.uniqueResult();
//assertTrue( Hibernate.isInitialized( b.getMapComponent().getFummap() ) );
assertTrue( Hibernate.isInitialized( b.getMapComponent().getStringmap() ) );
assertTrue( b.getMapComponent().getFummap().size()==1 );
assertTrue( b.getMapComponent().getStringmap().size()==2 );
s.delete(b);
s.flush();
s.connection().commit();
s.close();
}
示例10: testCriteria
import org.hibernate.criterion.Expression; //导入依赖的package包/类
public void testCriteria() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
Lower l = new Lower();
s.save(l);
assertTrue( l==s.createCriteria(Top.class).uniqueResult() );
s.delete(l);
s.flush();
Criteria c = s.createCriteria(Lower.class);
c.createCriteria("yetanother")
.add( Expression.isNotNull("id") )
.createCriteria("another");
c.createCriteria("another").add( Expression.isNotNull("id") );
c.list();
t.commit();
s.close();
}
示例11: testManyToManyFilterOnCriteria
import org.hibernate.criterion.Expression; //导入依赖的package包/类
public void testManyToManyFilterOnCriteria() {
TestData testData = new TestData();
testData.prepare();
Session session = openSession();
session.enableFilter( "effectiveDate" ).setParameter( "asOfDate", new Date() );
Product prod = ( Product ) session.createCriteria( Product.class )
.setResultTransformer( new DistinctRootEntityResultTransformer() )
.add( Expression.eq( "id", testData.prod1Id ) )
.uniqueResult();
assertNotNull( prod );
assertEquals( "Incorrect Product.categories count for filter", 1, prod.getCategories().size() );
session.close();
testData.release();
}
示例12: getAttributeOrderCriteria
import org.hibernate.criterion.Expression; //导入依赖的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);
}
示例13: getComplexAttributeOrderCriteria
import org.hibernate.criterion.Expression; //导入依赖的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));
}
示例14: getBackComplexAttributeOrder
import org.hibernate.criterion.Expression; //导入依赖的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);
}
示例15: getCriteria
import org.hibernate.criterion.Expression; //导入依赖的package包/类
public DetachedCriteria getCriteria() {
DetachedCriteria crit = null;
if (type == null) {
type = ItemRFCSelector.RFC_ANY_TYPE;
}
if (type.equals(ItemRFCSelector.RFC_ANY_TYPE)) {
crit = DetachedCriteria.forClass(RFC.class);
} else if (type.equals(ItemRFCSelector.RFC_MODIFY_VALUE_TYPE)) {
crit = DetachedCriteria.forClass(RFCModifyAttributeValue.class);
} else if (type.equals(ItemRFCSelector.RFC_NEW_CI_TYPE)) {
crit = DetachedCriteria.forClass(RFCNewCi.class);
}
//crit.addOrder( Order.desc("ts") );
if (this.txId != null) {
crit.add(Expression.eq("txId", this.txId));
}
return(crit);
}