use of javax.persistence.metamodel.Attribute in project jbpm by kiegroup.
the class QueryCriteriaUtil method createPredicateFromSingleCriteria.
/**
* This method is the main method for creating a {@link Predicate} from a (non-group) {@link QueryCriteria} instance.
* </p>
* If it can not figure out how to create a {@link Predicate} from the given {@link QueryCriteria} instance,
* then the (abstract) {@link #implSpecificCreatePredicateFromSingleCriteria(CriteriaQuery, QueryCriteria, CriteriaBuilder, Root, Class)}
* method is called.
*
* @param query The {@link CriteriaQuery} that is being built
* @param criteria The given {@link QueryCriteria} instance
* @param builder The {@link CriteriaBuilder} builder instance
* @param queryType The (persistent {@link Entity}) {@link Class} that we are querying on
* @return A {@link Predicate} created on the basis of the given {@link QueryCriteria}
*/
private <R, T> Predicate createPredicateFromSingleCriteria(CriteriaQuery<R> query, CriteriaBuilder builder, Class<T> queryType, QueryCriteria criteria, QueryWhere queryWhere) {
Predicate predicate = null;
assert criteria.hasValues() || criteria.hasDateValues() || Integer.parseInt(criteria.getListId()) < 0 : "No values present for criteria with list id: [" + criteria.getListId() + "]";
String listId = criteria.getListId();
Attribute attr = getCriteriaAttributes().get(queryType).get(listId);
if (attr != null) {
Expression entityField = getEntityField(query, listId, attr);
predicate = basicCreatePredicateFromSingleCriteria(builder, entityField, criteria);
} else {
predicate = implSpecificCreatePredicateFromSingleCriteria(query, builder, queryType, criteria, queryWhere);
}
return predicate;
}
use of javax.persistence.metamodel.Attribute in project querydsl by querydsl.
the class JPAPathBuilderValidator method validate.
@Override
public Class<?> validate(Class<?> parent, String property, Class<?> propertyType) {
try {
ManagedType managedType = metamodel.managedType(parent);
Attribute attribute = managedType.getAttribute(property);
if (attribute instanceof PluralAttribute) {
return ((PluralAttribute) attribute).getElementType().getJavaType();
} else {
return PrimitiveUtils.wrap(attribute.getJavaType());
}
} catch (IllegalArgumentException e) {
return null;
}
}
use of javax.persistence.metamodel.Attribute in project midpoint by Evolveum.
the class EntityRegistry method hasAttributePathOverride.
public boolean hasAttributePathOverride(ManagedType<?> type, ItemPath pathOverride) {
Map<UniformItemPath, Attribute<?, ?>> overrides = attributeNamePathOverrides.get(type);
if (overrides == null) {
return false;
}
ItemPath namedOnly = pathOverride.namedSegmentsOnly();
for (UniformItemPath path : overrides.keySet()) {
if (path.isSuperPathOrEquivalent(namedOnly)) {
return true;
}
}
return false;
}
use of javax.persistence.metamodel.Attribute in project hibernate-orm by hibernate.
the class AbstractFromImpl method joinList.
@Override
@SuppressWarnings({ "unchecked" })
public <X, Y> ListJoin<X, Y> joinList(String attributeName, JoinType jt) {
final Attribute<X, ?> attribute = (Attribute<X, ?>) locateAttribute(attributeName);
if (!attribute.isCollection()) {
throw new IllegalArgumentException("Requested attribute was not a list");
}
final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
if (!PluralAttribute.CollectionType.LIST.equals(pluralAttribute.getCollectionType())) {
throw new IllegalArgumentException("Requested attribute was not a list");
}
return (ListJoin<X, Y>) join((ListAttribute) attribute, jt);
}
use of javax.persistence.metamodel.Attribute in project hibernate-orm by hibernate.
the class AbstractFromImpl method joinMap.
@Override
@SuppressWarnings({ "unchecked" })
public <X, K, V> MapJoin<X, K, V> joinMap(String attributeName, JoinType jt) {
final Attribute<X, ?> attribute = (Attribute<X, ?>) locateAttribute(attributeName);
if (!attribute.isCollection()) {
throw new IllegalArgumentException("Requested attribute was not a map");
}
final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
if (!PluralAttribute.CollectionType.MAP.equals(pluralAttribute.getCollectionType())) {
throw new IllegalArgumentException("Requested attribute was not a map");
}
return (MapJoin<X, K, V>) join((MapAttribute) attribute, jt);
}
Aggregations