本文整理了Java中org.hibernate.Criteria.createCriteria()
方法的一些代码示例,展示了Criteria.createCriteria()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Criteria.createCriteria()
方法的具体详情如下:
包路径:org.hibernate.Criteria
类名称:Criteria
方法名:createCriteria
[英]Create a new Criteria, "rooted" at the associated entity.
Functionally equivalent to #createCriteria(String,org.hibernate.sql.JoinType) using JoinType#INNER_JOIN for the joinType.
[中]在关联实体处创建新标准“根”。
功能上等同于使用JoinType为JoinType的#createCriteria(String,org.hibernate.sql.JoinType)。
代码示例来源:origin: hibernate/hibernate-orm
/**
* Creates a nested DetachedCriteria representing the association path.
*
* @param associationPath The association path
*
* @return the newly created, nested DetachedCriteria
*/
public DetachedCriteria createCriteria(String associationPath) {
return new DetachedCriteria( impl, criteria.createCriteria( associationPath ) );
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Creates a nested DetachedCriteria representing the association path, specifying the type of join to use.
*
* @param associationPath The association path
* @param alias The alias to associate with this "join".
* @param joinType The type of join to use
*
* @return the newly created, nested DetachedCriteria
*/
public DetachedCriteria createCriteria(String associationPath, String alias, JoinType joinType) {
return new DetachedCriteria( impl, criteria.createCriteria( associationPath, alias, joinType ) );
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Creates a nested DetachedCriteria representing the association path.
*
* @param associationPath The association path
* @param alias The alias to apply to that association path
*
* @return the newly created, nested DetachedCriteria
*/
public DetachedCriteria createCriteria(String associationPath, String alias) {
return new DetachedCriteria( impl, criteria.createCriteria( associationPath, alias ) );
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Creates a nested DetachedCriteria representing the association path, specifying the type of join to use.
*
* @param associationPath The association path
* @param joinType The type of join to use
*
* @return the newly created, nested DetachedCriteria
*/
public DetachedCriteria createCriteria(String associationPath, JoinType joinType) {
return new DetachedCriteria( impl, criteria.createCriteria( associationPath, joinType ) );
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Creates a nested DetachedCriteria representing the association path, specifying the type of join to use and
* an additional join restriction.
*
* @param associationPath The association path
* @param alias The alias to associate with this "join".
* @param joinType The type of join to use
* @param withClause The additional join restriction
*
* @return the newly created, nested DetachedCriteria
*/
public DetachedCriteria createCriteria(String associationPath, String alias, JoinType joinType, Criterion withClause) {
return new DetachedCriteria(impl, criteria.createCriteria( associationPath, alias, joinType, withClause ) );
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testCriteriaRestrictionOnKeyManyToOne() {
Session s = openSession();
s.beginTransaction();
s.createQuery( "from Order o where o.customer.name = 'Acme'" ).list();
Criteria criteria = s.createCriteria( Order.class );
criteria.createCriteria( "customer" ).add( Restrictions.eq( "name", "Acme" ) );
criteria.list();
s.getTransaction().commit();
s.close();
}
代码示例来源:origin: hibernate/hibernate-orm
protected Criteria getCriteria(Session s) {
// should use RootEntityTransformer by default
return s.createCriteria( Student.class, "s" )
.createCriteria( "s.enrolments", "e", Criteria.LEFT_JOIN )
.addOrder( Order.asc( "s.studentNumber") );
}
};
代码示例来源:origin: hibernate/hibernate-orm
protected Criteria getCriteria(Session s) {
// should use RootEntityTransformer by default
return s.createCriteria( Student.class, "s" )
.createCriteria( "s.addresses", Criteria.LEFT_JOIN )
.addOrder( Order.asc( "s.studentNumber") );
}
};
代码示例来源:origin: hibernate/hibernate-orm
protected Criteria getCriteria(Session s) {
// should use RootEntityTransformer by default
return s.createCriteria( Student.class, "s" )
.createCriteria( "s.addresses", "a", Criteria.LEFT_JOIN )
.addOrder( Order.asc( "s.studentNumber") );
}
};
代码示例来源:origin: hibernate/hibernate-orm
protected Criteria getCriteria(Session s) {
// should use RootEntityTransformer by default
return s.createCriteria( Student.class, "s" )
.createCriteria( "s.preferredCourse", Criteria.LEFT_JOIN )
.addOrder( Order.asc( "s.studentNumber") );
}
};
代码示例来源:origin: hibernate/hibernate-orm
protected Criteria getCriteria(Session s) {
// should use RootEntityTransformer by default
return s.createCriteria( Student.class, "s" )
.createCriteria( "s.preferredCourse", "p", Criteria.LEFT_JOIN )
.addOrder( Order.asc( "s.studentNumber") );
}
};
代码示例来源:origin: hibernate/hibernate-orm
protected Criteria getCriteria(Session s) {
// should use RootEntityTransformer by default
return s.createCriteria( Student.class, "s" )
.createCriteria( "s.enrolments", Criteria.LEFT_JOIN )
.addOrder( Order.asc( "s.studentNumber") );
}
};
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testDiscriminatorFiltering() throws Exception {
if ( ( getDialect() instanceof HSQLDialect ) ) return;
Session s = openSession();
Transaction t = s.beginTransaction();
s.createQuery("from C1 c1 left join c1.c2s c2").list();
s.createCriteria(C1.class).createCriteria("c2s").list();
t.commit();
s.close();
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
@TestForIssue( jiraKey = "HHH-7767" )
public void testCriteriaRestrictionOnIdManyToOne() {
Session s = openSession();
s.beginTransaction();
s.createQuery( "from Course c join c.students cs join cs.student s where s.name = 'Foo'" ).list();
Criteria criteria = s.createCriteria( Course.class );
criteria.createCriteria( "students" ).createCriteria( "student" ).add( Restrictions.eq( "name", "Foo" ) );
criteria.list();
Criteria criteria2 = s.createCriteria( Course.class );
criteria2.createAlias( "students", "cs" );
criteria2.add( Restrictions.eq( "cs.value", "Bar" ) );
criteria2.createAlias( "cs.student", "s" );
criteria2.add( Restrictions.eq( "s.name", "Foo" ) );
criteria2.list();
s.getTransaction().commit();
s.close();
}
代码示例来源:origin: hibernate/hibernate-orm
protected Criteria getCriteria(Session s) {
// should use RootEntityTransformer by default
return s.createCriteria( Student.class, "s" )
.createCriteria( "s.preferredCourse", "pCourse", Criteria.LEFT_JOIN )
.setFetchMode( "preferredCourse", FetchMode.JOIN )
.addOrder( Order.asc( "s.studentNumber") );
}
};
代码示例来源:origin: hibernate/hibernate-orm
protected Criteria getCriteria(Session s) {
// should use RootEntityTransformer by default
return s.createCriteria( Student.class, "s" )
.createCriteria( "s.addresses", "a", Criteria.LEFT_JOIN )
.setFetchMode( "a", FetchMode.JOIN )
.addOrder( Order.asc( "s.studentNumber") );
}
};
代码示例来源:origin: hibernate/hibernate-orm
protected Criteria getCriteria(Session s) {
// should use RootEntityTransformer by default
return s.createCriteria( Student.class, "s" )
.createCriteria( "s.preferredCourse", "pCourse", Criteria.LEFT_JOIN )
.setFetchMode( "pCourse", FetchMode.JOIN )
.addOrder( Order.asc( "s.studentNumber") );
}
};
代码示例来源:origin: hibernate/hibernate-orm
protected Criteria getCriteria(Session s) {
// should use RootEntityTransformer by default
return s.createCriteria( Student.class, "s" )
.createCriteria( "s.addresses", "a", Criteria.LEFT_JOIN )
.setFetchMode( "addresses", FetchMode.JOIN )
.addOrder( Order.asc( "s.studentNumber") );
}
};
代码示例来源:origin: hibernate/hibernate-orm
private EntityMapEnum assertFindCriteria(
EntityMapEnum expected,
String mapPath, Object param) {
assertNotEquals( 0, expected.id );
Session session = openNewSession();
session.beginTransaction();
EntityMapEnum found = (EntityMapEnum) session.createCriteria( EntityMapEnum.class )
.createCriteria( mapPath, "m" )
.add( Restrictions.eq( "indices", param ) )
.uniqueResult();
//find
assetEntityMapEnumEquals( expected, found );
session.getTransaction().commit();
session.close();
return found;
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
protected Criteria getCriteria(Session s) {
return s.createCriteria( Student.class, "s" )
.createAlias( "s.addresses", "a", CriteriaSpecification.LEFT_JOIN )
.setResultTransformer( CriteriaSpecification.ALIAS_TO_ENTITY_MAP )
.createCriteria( "s.preferredCourse", CriteriaSpecification.INNER_JOIN )
.addOrder( Order.asc( "s.studentNumber") );
}
};
内容来源于网络,如有侵权,请联系作者删除!