本文整理汇总了Java中org.hibernate.criterion.Conjunction类的典型用法代码示例。如果您正苦于以下问题:Java Conjunction类的具体用法?Java Conjunction怎么用?Java Conjunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Conjunction类属于org.hibernate.criterion包,在下文中一共展示了Conjunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findMatchingName
import org.hibernate.criterion.Conjunction; //导入依赖的package包/类
/**
* Search staff list for instructors with matching names
* @param fname First Name
* @param lname Last Name
* @return
*/
public static List findMatchingName(String fname, String lname) {
List list = null;
if ( (fname==null || fname.trim().length()==0)
&& (lname==null || lname.trim().length()==0) )
return list;
Conjunction and = Restrictions.conjunction();
if (fname!=null && fname.trim().length()>0)
and.add(Restrictions.ilike("firstName", fname, MatchMode.START));
if (lname!=null && lname.trim().length()>0)
and.add(Restrictions.ilike("lastName", lname, MatchMode.START));
StaffDAO sdao = new StaffDAO();
list = sdao.getSession()
.createCriteria(Staff.class)
.add(and)
.list();
Collections.sort(list);
return list;
}
示例2: getAllLikeName
import org.hibernate.criterion.Conjunction; //导入依赖的package包/类
@Override
@SuppressWarnings( "unchecked" )
public List<T> getAllLikeName( Set<String> nameWords, int first, int max )
{
Conjunction conjunction = Restrictions.conjunction();
for ( String word : nameWords )
{
conjunction.add( Restrictions.like( "name", "%" + word + "%" ).ignoreCase() );
}
return getSharingCriteria()
.add( conjunction )
.addOrder( Order.asc( "name" ) )
.setFirstResult( first )
.setMaxResults( max )
.list();
}
示例3: handleCondtion
import org.hibernate.criterion.Conjunction; //导入依赖的package包/类
private Criterion handleCondtion(Condition first) {
if (first == null) {
return null;
}
Map<String, Object> map = first.getEqs();
if (map.isEmpty()) {
return null;
}
Conjunction conJoin = Restrictions.conjunction();
for (Map.Entry<String, Object> item : map.entrySet()) {
Object value = item.getValue();
if(value==null){
conJoin.add(Restrictions.isNull(item.getKey()));
}else{
conJoin.add(Restrictions.eq(item.getKey(), value));
}
}
return conJoin;
}
示例4: getDatumJunction
import org.hibernate.criterion.Conjunction; //导入依赖的package包/类
private Junction getDatumJunction(AdvancedSampleSearchBean searchBean) {
// if AND and more than one type of datum, don't use junction
if (searchBean.getCharacterizationLogicalOperator().equals("and")
&& searchBean.getDatumTypeCount() > 1) {
return null;
}
Disjunction datumDisjunction = Restrictions.disjunction();
Conjunction datumConjunction = Restrictions.conjunction();
for (CharacterizationQueryBean charQuery : searchBean
.getCharacterizationQueries()) {
Criterion datumCrit = getDatumCriterion(charQuery);
if (datumCrit != null) {
datumDisjunction.add(datumCrit);
if (searchBean.getDatumTypeCount() == 1) {
datumConjunction.add(datumCrit);
}
}
}
// default to or if only one query
Junction junction = (searchBean.getCharacterizationLogicalOperator()
.equals("or") || searchBean.getCharacterizationQueries().size() == 1) ? datumDisjunction
: datumConjunction;
return junction;
}
示例5: getSampleNameJunction
import org.hibernate.criterion.Conjunction; //导入依赖的package包/类
/**
* Get the sample name junction used in sample queries
*
* @param searchBean
* @param crit
* @return
* @throws Exception
*/
private Junction getSampleNameJunction(AdvancedSampleSearchBean searchBean)
throws Exception {
Disjunction sampleDisjunction = Restrictions.disjunction();
Conjunction sampleConjunction = Restrictions.conjunction();
for (SampleQueryBean query : searchBean.getSampleQueries()) {
if (query.getNameType().equals("sample name")) {
Criterion sampleNameCrit = getSampleNameCriterion(query);
if (sampleNameCrit != null) {
sampleDisjunction.add(sampleNameCrit);
sampleConjunction.add(sampleNameCrit);
}
}
}
Junction junction = (searchBean.getSampleLogicalOperator().equals("or") || searchBean
.getSampleQueries().size() == 1) ? sampleDisjunction
: sampleConjunction;
return junction;
}
示例6: setSeriesSecurityGroups
import org.hibernate.criterion.Conjunction; //导入依赖的package包/类
private static void setSeriesSecurityGroups(DetachedCriteria criteria, List<String> securityGroups)
{
Conjunction con = new Conjunction();
if (securityGroups != null && securityGroups.size() != 0)
{
Disjunction disjunction = Restrictions.disjunction();
disjunction.add(Restrictions.isNull("securityGroup"));
disjunction.add(Restrictions.in("securityGroup", securityGroups));
con.add(disjunction);
criteria.add(con);
}
else
{
criteria.add(Restrictions.isNull("securityGroup"));
}
}
示例7: saidaTodosEquipamentos
import org.hibernate.criterion.Conjunction; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public List <Saida> saidaTodosEquipamentos(List<Equipamento> equipamentos) {
Criteria criteria = session.createCriteria(Saida.class, "s");
Conjunction c = Restrictions.conjunction();
for (Equipamento e : equipamentos) {
c.add(Subqueries.exists(
DetachedCriteria.forClass(SaidaEquipamento.class, "se")
.setProjection(Projections.id())
.add(Restrictions.eqProperty("s.id", "se.saida.id"))
.add(Restrictions.eq("se.equipamento",e))));
}
criteria.add(c);
return criteria.list();
}
示例8: parseFilter
import org.hibernate.criterion.Conjunction; //导入依赖的package包/类
private Criteria parseFilter( Criteria criteria, List<String> filters )
{
Conjunction conjunction = Restrictions.conjunction();
Schema schema = schemaService.getDynamicSchema( MinMaxDataElement.class );
if ( !filters.isEmpty() )
{
for ( String filter : filters )
{
String[] split = filter.split( ":" );
if ( split.length != 3 )
{
throw new QueryParserException( "Invalid filter: " + filter );
}
QueryPath queryPath = queryPlanner.getQueryPath( schema, split[0] );
Property property = queryParser.getProperty( schema, split[0] );
Criterion restriction = getRestriction( property, queryPath.getPath(), split[1], split[2] );
if ( restriction != null )
{
conjunction.add( restriction );
if ( queryPath.haveAlias() )
{
for ( String alias : queryPath.getAlias() )
{
criteria.createAlias( alias, alias );
}
}
}
}
}
criteria.add( conjunction );
return criteria;
}
示例9: buildAccountsPropertiesConjunction
import org.hibernate.criterion.Conjunction; //导入依赖的package包/类
/**
* Builds a conjunction by the properties of accounts.
*
* @param banned null for not query
* @param twitchToken null for not query, empty for no token
* @return conjunction
*/
private Conjunction buildAccountsPropertiesConjunction(Boolean banned, String twitchToken) {
Conjunction conjunction = conjunction();
if (banned != null) {
conjunction.add(eq("banned", banned));
}
if (twitchToken != null) {
conjunction.add(eqOrIsNull("twitchToken", emptyToNull(twitchToken)));
}
return conjunction;
}
示例10: getCriterion
import org.hibernate.criterion.Conjunction; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Criterion getCriterion() {
Conjunction conjunction = Restrictions.conjunction();
for(Filter filter : getFilters()) {
conjunction.add(filter.getCriterion());
}
return conjunction;
}
示例11: getFunctionJunction
import org.hibernate.criterion.Conjunction; //导入依赖的package包/类
/**
* Get the junction used in function queries
*
* @param searchBean
* @param crit
* @return
* @throws Exception
*/
private Junction getFunctionJunction(AdvancedSampleSearchBean searchBean,
DetachedCriteria crit) throws Exception {
// if AND and more than one query per type, don't use junction
if (searchBean.getCompositionLogicalOperator().equals("and")
&& searchBean.getFuncCount() > 1) {
return null;
}
Disjunction compDisjunction = Restrictions.disjunction();
Conjunction compConjunction = Restrictions.conjunction();
for (CompositionQueryBean compQuery : searchBean
.getCompositionQueries()) {
// function
if (compQuery.getCompositionType().equals("function")) {
Criterion funcCrit = this.getFunctionCriterion(compQuery, "",
"");
if (funcCrit != null) {
compDisjunction.add(funcCrit);
// only add to conjunction if there is only one query for
// the type
if (searchBean.getFuncCount() == 1) {
compConjunction.add(funcCrit);
}
}
}
}
// default to or if only one query
Junction junction = (searchBean.getCompositionLogicalOperator().equals(
"or") || searchBean.getCompositionQueries().size() == 1) ? compDisjunction
: compConjunction;
return junction;
}
示例12: getNanomaterialEntityJunction
import org.hibernate.criterion.Conjunction; //导入依赖的package包/类
/**
* Get the junction used in nanomaterial entity queries
*
* @param searchBean
* @param crit
* @return
* @throws Exception
*/
private Junction getNanomaterialEntityJunction(
AdvancedSampleSearchBean searchBean, DetachedCriteria crit)
throws Exception {
// if AND and more than one query per type, don't use junction
if (searchBean.getCompositionLogicalOperator().equals("and")
&& searchBean.getNanoEntityCount() > 1) {
return null;
}
Disjunction compDisjunction = Restrictions.disjunction();
Conjunction compConjunction = Restrictions.conjunction();
for (CompositionQueryBean compQuery : searchBean
.getCompositionQueries()) {
// nanomaterial entity
if (compQuery.getCompositionType().equals("nanomaterial entity")) {
Criterion nanoEntityCrit = getNanomaterialEntityCriterion(
compQuery, "");
if (nanoEntityCrit != null) {
compDisjunction.add(nanoEntityCrit);
// only add to conjunction if there is only one query for
// the type
if (searchBean.getNanoEntityCount() == 1) {
compConjunction.add(nanoEntityCrit);
}
}
}
}
// default to or if only one query
Junction junction = (searchBean.getCompositionLogicalOperator().equals(
"or") || searchBean.getCompositionQueries().size() == 1) ? compDisjunction
: compConjunction;
return junction;
}
示例13: getFunctionalizingEntityJunction
import org.hibernate.criterion.Conjunction; //导入依赖的package包/类
/**
* Get the junction used in functionalizing entity queries
*
* @param searchBean
* @param crit
* @return
* @throws Exception
*/
private Junction getFunctionalizingEntityJunction(
AdvancedSampleSearchBean searchBean, DetachedCriteria crit)
throws Exception {
// if AND and more than one query per type, don't use junction
if (searchBean.getCompositionLogicalOperator().equals("and")
&& searchBean.getFuncEntityCount() > 1) {
return null;
}
Disjunction compDisjunction = Restrictions.disjunction();
Conjunction compConjunction = Restrictions.conjunction();
for (CompositionQueryBean compQuery : searchBean
.getCompositionQueries()) {
// functionalizing entity
if (compQuery.getCompositionType().equals("functionalizing entity")) {
Criterion funcEntityCrit = getFunctionalizingEntityCriterion(
compQuery, "");
if (funcEntityCrit != null) {
compDisjunction.add(funcEntityCrit);
// only add to conjunction if there is only one query for
// the type
if (searchBean.getFuncEntityCount() == 1) {
compConjunction.add(funcEntityCrit);
}
}
}
}
// default to or if only one query
Junction junction = (searchBean.getCompositionLogicalOperator().equals(
"or") || searchBean.getCompositionQueries().size() == 1) ? compDisjunction
: compConjunction;
return junction;
}
示例14: getSampleJunction
import org.hibernate.criterion.Conjunction; //导入依赖的package包/类
/**
* Get the sample disjunction used in sample queries
*
* @param searchBean
* @param crit
* @return
* @throws Exception
*/
private Junction getSampleJunction(AdvancedSampleSearchBean searchBean)
throws Exception {
// if there are more than one POC query in AND, don't use junction.
if (searchBean.getSampleLogicalOperator().equals("and")
&& searchBean.getPocCount() > 1) {
return null;
}
Disjunction sampleDisjunction = Restrictions.disjunction();
Conjunction sampleConjunction = Restrictions.conjunction();
for (SampleQueryBean query : searchBean.getSampleQueries()) {
if (query.getNameType().equals("sample name")) {
Criterion sampleNameCrit = getSampleNameCriterion(query);
if (sampleNameCrit != null) {
sampleDisjunction.add(sampleNameCrit);
sampleConjunction.add(sampleNameCrit);
}
}
if (query.getNameType().equals("point of contact name")) {
Disjunction pocDisjunction = getPointOfContactDisjunction(
searchBean, "poc.", "otherPOC.");
if (pocDisjunction != null) {
sampleDisjunction.add(pocDisjunction);
if (searchBean.getPocCount() == 1) {
sampleConjunction.add(pocDisjunction);
}
}
}
}
Junction junction = (searchBean.getSampleLogicalOperator().equals("or") || searchBean
.getSampleQueries().size() == 1) ? sampleDisjunction
: sampleConjunction;
return junction;
}
示例15: and
import org.hibernate.criterion.Conjunction; //导入依赖的package包/类
@Override
public Criterion and(Criterion... subqueries) {
Conjunction conjunction = Restrictions.conjunction();
for (Criterion criterion : subqueries) {
conjunction.add(criterion);
}
return conjunction;
}