本文整理汇总了Java中org.hibernate.criterion.Junction.add方法的典型用法代码示例。如果您正苦于以下问题:Java Junction.add方法的具体用法?Java Junction.add怎么用?Java Junction.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.criterion.Junction
的用法示例。
在下文中一共展示了Junction.add方法的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: 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;
}
示例4: 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);
}
}
示例5: 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);
}
示例6: 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();
}
示例7: 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;
}
示例8: 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);
}
示例9: 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);
}
示例10: addAnnotationCriterionValues
import org.hibernate.criterion.Junction; //导入方法依赖的package包/类
private void addAnnotationCriterionValues(Criteria c, Junction junction, Set<String> values,
String assocPath, String alias) {
if (!values.isEmpty()) {
c.createAlias(assocPath, alias);
junction.add(Restrictions.in(alias + ".value", values));
}
}
示例11: 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);
}
示例12: 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);
}
示例13: findGenesByLocation
import org.hibernate.criterion.Junction; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings(UNCHECKED) // Hibernate operations are untyped
public List<Gene> findGenesByLocation(String chromosome, Integer startPosition, Integer endPosition,
GenomeBuildVersionEnum genomeBuildVersion) {
String locStartPosition = "location.startPosition";
String locEndPosition = "location.endPosition";
Criteria geneLocationCriteria = getCurrentSession().createCriteria(GeneChromosomalLocation.class);
// (gene.startPos <= startPosition && gene.endPos >= startPosition)
// || (gene.startPos >= lowerInput && gene.startPos <= higherInput)
Junction overallOrStatement = Restrictions.disjunction();
overallOrStatement.add(Restrictions.conjunction().add(Restrictions.le(locStartPosition, startPosition))
.add(Restrictions.ge(locEndPosition, startPosition)));
overallOrStatement.add(Restrictions.conjunction().add(Restrictions.ge(locStartPosition, startPosition)).add(
Restrictions.le(locStartPosition, endPosition)));
geneLocationCriteria.add(overallOrStatement);
geneLocationCriteria.add(getChromosomeRestriction(chromosome));
geneLocationCriteria.createCriteria("geneLocationConfiguration").
add(Restrictions.eq("genomeBuildVersion", genomeBuildVersion));
geneLocationCriteria.setProjection(Projections.property("geneSymbol"));
List<String> geneSymbols = geneLocationCriteria.list();
return geneSymbols.isEmpty() ? new ArrayList<Gene>()
: getCurrentSession().createCriteria(Gene.class).setProjection(
Projections.distinct(Projections.property(SYMBOL_ATTRIBUTE))).
add(Restrictions.in(SYMBOL_ATTRIBUTE, geneSymbols)).
addOrder(Order.asc(SYMBOL_ATTRIBUTE)).list();
}
示例14: completeCriteriaWithTranslations
import org.hibernate.criterion.Junction; //导入方法依赖的package包/类
/**
* Complete criteria with translations.
*
* @param currentCriteria
* the current criteria
* @param translationsPath
* the translations path
* @param translationsAlias
* the translations alias
* @param property
* the property
* @param propertyDescriptor
* the property descriptor
* @param prefixedProperty
* the prefixed property
* @param locale
* the locale
* @param componentDescriptor
* the component descriptor
* @param queryComponent
* the query component
* @param context
* the context
*/
@SuppressWarnings("unchecked")
protected void completeCriteriaWithTranslations(DetachedCriteria currentCriteria, String translationsPath,
String translationsAlias, Map.Entry<String, Object> property,
IPropertyDescriptor propertyDescriptor, String prefixedProperty,
Locale locale, IComponentDescriptor<?> componentDescriptor,
IQueryComponent queryComponent, Map<String, Object> context) {
if (propertyDescriptor instanceof IStringPropertyDescriptor && ((IStringPropertyDescriptor) propertyDescriptor)
.isTranslatable()) {
String nlsOrRawValue = null;
String nlsValue = (String) property.getValue();
String barePropertyName = property.getKey();
if (property.getKey().endsWith(IComponentDescriptor.NLS_SUFFIX)) {
barePropertyName = barePropertyName.substring(0,
barePropertyName.length() - IComponentDescriptor.NLS_SUFFIX.length());
} else {
nlsOrRawValue = nlsValue;
}
if (nlsValue != null) {
Junction translationRestriction = Restrictions.conjunction();
translationRestriction.add(createStringRestriction(
((ICollectionPropertyDescriptor<IPropertyTranslation>) componentDescriptor.getPropertyDescriptor(
translationsPath)).getCollectionDescriptor().getElementDescriptor().getPropertyDescriptor(
IPropertyTranslation.TRANSLATED_VALUE), translationsAlias + "." + IPropertyTranslation.TRANSLATED_VALUE,
nlsValue, componentDescriptor, queryComponent, context));
String languagePath = translationsAlias + "." + IPropertyTranslation.LANGUAGE;
translationRestriction.add(Restrictions.eq(languagePath, locale.getLanguage()));
translationRestriction.add(Restrictions.eq(translationsAlias + "." + IPropertyTranslation.PROPERTY_NAME,
barePropertyName));
Junction disjunction = Restrictions.disjunction();
disjunction.add(translationRestriction);
if (nlsOrRawValue != null) {
Junction rawValueRestriction = Restrictions.conjunction();
rawValueRestriction.add(Restrictions.disjunction().add(Restrictions.isNull(languagePath)).add(Restrictions.ne(
languagePath, locale.getLanguage())));
String rawPropertyName = barePropertyName + IComponentDescriptor.RAW_SUFFIX;
rawValueRestriction.add(createStringRestriction(componentDescriptor.getPropertyDescriptor(rawPropertyName),
rawPropertyName, nlsOrRawValue, componentDescriptor, queryComponent, context));
disjunction.add(rawValueRestriction);
}
currentCriteria.add(disjunction);
}
} else {
completeCriteria(currentCriteria, createStringRestriction(propertyDescriptor, prefixedProperty,
(String) property.getValue(), componentDescriptor, queryComponent, context));
}
}
示例15: createStringRestriction
import org.hibernate.criterion.Junction; //导入方法依赖的package包/类
/**
* Creates a string based restriction.
*
* @param propertyDescriptor
* the property descriptor.
* @param prefixedProperty
* the full path of the property.
* @param propertyValue
* the string property value.
* @param componentDescriptor
* the component descriptor
* @param queryComponent
* the query component
* @param context
* the context
* @return the created criterion or null if no criterion necessary.
*/
protected Criterion createStringRestriction(IPropertyDescriptor propertyDescriptor, String prefixedProperty,
String propertyValue, IComponentDescriptor<?> componentDescriptor,
IQueryComponent queryComponent, Map<String, Object> context) {
Junction disjunction = null;
if (propertyValue.length() > 0) {
String[] stringDisjunctions = propertyValue.split(IQueryComponent.DISJUNCT);
disjunction = Restrictions.disjunction();
for (String stringDisjunction : stringDisjunctions) {
Junction conjunction = Restrictions.conjunction();
String[] stringConjunctions = stringDisjunction.split(IQueryComponent.CONJUNCT);
for (String stringConjunction : stringConjunctions) {
String val = stringConjunction;
if (val.length() > 0) {
Criterion crit;
boolean negate = false;
if (val.startsWith(IQueryComponent.NOT_VAL)) {
val = val.substring(1);
negate = true;
}
if (IQueryComponent.NULL_VAL.equals(val)) {
crit = Restrictions.isNull(prefixedProperty);
} else {
if (IEntity.ID.equals(propertyDescriptor.getName())
|| propertyDescriptor instanceof IEnumerationPropertyDescriptor) {
crit = Restrictions.eq(prefixedProperty, val);
} else {
crit = createLikeRestriction(propertyDescriptor, prefixedProperty, val, componentDescriptor,
queryComponent, context);
}
}
if (negate) {
crit = Restrictions.not(crit);
}
conjunction.add(crit);
}
}
disjunction.add(conjunction);
}
}
return disjunction;
}