本文整理汇总了Java中org.hibernate.criterion.Junction类的典型用法代码示例。如果您正苦于以下问题:Java Junction类的具体用法?Java Junction怎么用?Java Junction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Junction类属于org.hibernate.criterion包,在下文中一共展示了Junction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCriteria
import org.hibernate.criterion.Junction; //导入依赖的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);
}
示例2: createEnumQueryStructureRestriction
import org.hibernate.criterion.Junction; //导入依赖的package包/类
/**
* Complements a criteria by processing an enumeration query structure.
*
* @param path
* the path to the comparable property.
* @param enumQueryStructure
* the collection of checked / unchecked enumeration values.
* @return the created criterion or null if no criterion necessary.
*/
protected Criterion createEnumQueryStructureRestriction(String path, EnumQueryStructure enumQueryStructure) {
Set<String> inListValues = new HashSet<>();
boolean nullAllowed = false;
for (EnumValueQueryStructure inListValue : enumQueryStructure.getSelectedEnumerationValues()) {
if (inListValue.getValue() == null || "".equals(inListValue.getValue())) {
nullAllowed = true;
} else {
inListValues.add(inListValue.getValue());
}
}
Junction queryStructureRestriction = null;
if (!inListValues.isEmpty() || nullAllowed) {
queryStructureRestriction = Restrictions.disjunction();
if (!inListValues.isEmpty()) {
queryStructureRestriction.add(Restrictions.in(path, inListValues));
}
if (nullAllowed) {
queryStructureRestriction.add(Restrictions.isNull(path));
}
}
return queryStructureRestriction;
}
示例3: getDatumJunction
import org.hibernate.criterion.Junction; //导入依赖的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;
}
示例4: getSampleNameJunction
import org.hibernate.criterion.Junction; //导入依赖的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;
}
示例5: applySearchFilters
import org.hibernate.criterion.Junction; //导入依赖的package包/类
public boolean applySearchFilters(Criteria criteria, String searchTerm) {
boolean filterAdded = false;
//If search string is integer type, it only searches on Id field
if (NumberUtils.isDigits(searchTerm)) {
criteria.add(Restrictions.eq(getIdField(), Integer.parseInt(searchTerm)));
filterAdded = true;
} else if (getSearchFields() != null && getSearchFields().size() != 0) {
//Text filtering is applied only if you have specified getSearchFields().
String likeTerm = "%" + searchTerm + "%";
Junction disjunction = Restrictions.disjunction();
for (String field : getSearchFields()) {
//Performs case insensitive search on all search fields.
//Also does not searches on associations. Only value types are searched.
disjunction.add(Restrictions.ilike(field, likeTerm));
}
criteria.add(disjunction);
filterAdded = true;
}
return filterAdded;
}
示例6: addChromosomeCoordinatesToCriterion
import org.hibernate.criterion.Junction; //导入依赖的package包/类
private void addChromosomeCoordinatesToCriterion(Integer chromosomeCoordinateHigh,
Integer chromosomeCoordinateLow, Criteria segmentDataCrit, String chromosomeNumber) {
if (chromosomeCoordinateHigh == null || chromosomeCoordinateLow == null) {
segmentDataCrit.add(chromosomeNumberExpression(chromosomeNumber));
if (chromosomeCoordinateHigh != null) {
segmentDataCrit.add(segmentEndLessThanHigh(chromosomeCoordinateHigh));
}
if (chromosomeCoordinateLow != null) {
segmentDataCrit.add(segmentStartGreaterThanLow(chromosomeCoordinateLow));
}
} else {
Junction overallOrStatement = Restrictions.disjunction();
// (loc.startPos <= lowerInput && loc.endPos >= lowerInput && loc.chromosome == chromosomeInput)
// || (loc.startPos >= lowerInput && loc.startPos <= higherInput && loc.chromosome == chromosomeInput)
overallOrStatement.add(Restrictions.conjunction().add(segmentStartLessThanLow(chromosomeCoordinateLow))
.add(segmentEndGreaterThanLow(chromosomeCoordinateLow)).add(
chromosomeNumberExpression(chromosomeNumber)));
overallOrStatement.add(Restrictions.conjunction().add(segmentStartGreaterThanLow(chromosomeCoordinateLow))
.add(segmentStartLessThanHigh(chromosomeCoordinateHigh)).add(
chromosomeNumberExpression(chromosomeNumber)));
segmentDataCrit.add(overallOrStatement);
}
}
示例7: addMultipleChromosomeCoordinatesToCriterion
import org.hibernate.criterion.Junction; //导入依赖的package包/类
private void addMultipleChromosomeCoordinatesToCriterion(Criteria segmentDataCrit,
List<GeneChromosomalLocation> geneLocations) {
Junction overallOrStatement = Restrictions.disjunction();
// (loc.startPos <= lowerInput && loc.endPos >= lowerInput && loc.chromosome == chromosomeInput)
// || (loc.startPos >= lowerInput && loc.startPos <= higherInput && loc.chromosome == chromosomeInput)
for (GeneChromosomalLocation geneLocation : geneLocations) {
Integer chromosomeCoordinateLow = geneLocation.getLocation().getStartPosition();
Integer chromosomeCoordinateHigh = geneLocation.getLocation().getEndPosition();
overallOrStatement.add(Restrictions.conjunction().add(segmentStartLessThanLow(chromosomeCoordinateLow))
.add(segmentEndGreaterThanLow(chromosomeCoordinateLow)).add(
chromosomeNumberExpression(Cai2Util.getInternalChromosomeNumber(
geneLocation.getLocation().getChromosome()))));
overallOrStatement.add(Restrictions.conjunction().add(segmentStartGreaterThanLow(chromosomeCoordinateLow))
.add(segmentStartLessThanHigh(chromosomeCoordinateHigh)).add(
chromosomeNumberExpression(Cai2Util.getInternalChromosomeNumber(
geneLocation.getLocation().getChromosome()))));
}
segmentDataCrit.add(overallOrStatement);
}
示例8: findMatchingSegmentDatasByLocation
import org.hibernate.criterion.Junction; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings(UNCHECKED) // Hibernate operations are untyped
public List<SegmentData> findMatchingSegmentDatasByLocation(List<SegmentData> segmentDatasToMatch,
Study study, Platform platform) {
Criteria segmentDataCrit = getCurrentSession().createCriteria(SegmentData.class);
Criteria arrayDataCrit = segmentDataCrit.createCriteria("arrayData");
Criteria reporterListsCrit = arrayDataCrit.createCriteria("reporterLists");
reporterListsCrit.add(Restrictions.eq(PLATFORM_ASSOCIATION, platform));
arrayDataCrit.add(Restrictions.eq(STUDY_ASSOCIATION, study));
Junction overallOrStatement = Restrictions.disjunction();
for (SegmentData segmentData : segmentDatasToMatch) {
ChromosomalLocation location = segmentData.getLocation();
overallOrStatement.add(Restrictions.conjunction().
add(Restrictions.eq("Location.startPosition", location.getStartPosition())).
add(Restrictions.eq("Location.endPosition", location.getEndPosition())));
}
segmentDataCrit.add(overallOrStatement);
return segmentDataCrit.list();
}
示例9: applyCategoryCriterion
import org.hibernate.criterion.Junction; //导入依赖的package包/类
private static boolean applyCategoryCriterion(Object criteriaJunction, CategoryCriterion categoryCriterion) {
Criterion restriction = getCategoryCriterionRestriction(categoryCriterion);
if (restriction != null) {
if (criteriaJunction instanceof Criteria) {
((Criteria) criteriaJunction).add(restriction);
return true;
} else if (criteriaJunction instanceof Junction) {
((Junction) criteriaJunction).add(restriction);
return true;
}
}
return false;
}
示例10: applyCategoryCriterions
import org.hibernate.criterion.Junction; //导入依赖的package包/类
private static void applyCategoryCriterions(Criteria criteria, Junction junction, CategoryCriterion... categoryCriterions) {
if (criteria != null && junction != null && categoryCriterions != null) {
if (categoryCriterions.length > 0) {
boolean applied = false;
for (int i = 0; i < categoryCriterions.length; i++) {
applied |= applyCategoryCriterion(junction, categoryCriterions[i]);
}
if (applied) {
criteria.add(junction);
}
}
}
}
示例11: createCriterion
import org.hibernate.criterion.Junction; //导入依赖的package包/类
private Criterion createCriterion(CriteriaWrapper crit, AndOrPredicate pred,
String contextAlias) {
Operator op = pred.getOperator();
Junction junction = (op == Operator.And) ? Restrictions.conjunction()
: Restrictions.disjunction();
for (Predicate subPred : pred.getPredicates()) {
Criterion cr = toCriterion(crit, subPred, contextAlias);
junction.add(cr);
}
return junction;
}
示例12: visitAllComplete
import org.hibernate.criterion.Junction; //导入依赖的package包/类
@Override
public void visitAllComplete(final AllRestriction restriction) {
final int restrictionSize = restriction.getRestrictions().size();
final int criterionSize = m_criterions.size();
if (criterionSize < restrictionSize) {
throw new IllegalStateException("AllRestriction with " + restrictionSize + " entries encountered, but we only have " + criterionSize + " criterions!");
}
final List<Criterion> criterions = m_criterions.subList(criterionSize - restrictionSize, criterionSize);
final Junction j = org.hibernate.criterion.Restrictions.conjunction();
for (final Criterion crit : criterions) {
j.add(crit);
}
criterions.clear();
m_criterions.add(j);
}
示例13: visitAnyComplete
import org.hibernate.criterion.Junction; //导入依赖的package包/类
@Override
public void visitAnyComplete(final AnyRestriction restriction) {
final int restrictionSize = restriction.getRestrictions().size();
final int criterionSize = m_criterions.size();
if (criterionSize < restrictionSize) {
throw new IllegalStateException("AllRestriction with " + restrictionSize + " entries encountered, but we only have " + criterionSize + " criterions!");
}
final List<Criterion> criterions = m_criterions.subList(criterionSize - restrictionSize, criterionSize);
final Junction j = org.hibernate.criterion.Restrictions.disjunction();
for (final Criterion crit : criterions) {
j.add(crit);
}
criterions.clear();
m_criterions.add(j);
}
示例14: getFunctionJunction
import org.hibernate.criterion.Junction; //导入依赖的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;
}
示例15: getNanomaterialEntityJunction
import org.hibernate.criterion.Junction; //导入依赖的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;
}