public ScalarTargetResolvingExpressionVisitor(Class<?> managedType, EntityMetamodel metamodel, Map<String, JpqlFunction> functions) { this(metamodel.managedType(managedType), metamodel, functions); }
public static ManagedType<?> getManagedType(EntityMetamodel metamodel, Class<?> managedTypeClass, String treatTypeName) { if (treatTypeName != null) { ManagedType<?> type = metamodel.managedType(treatTypeName); if (!managedTypeClass.isAssignableFrom(type.getJavaType())) { throw new IllegalArgumentException("Treat type '" + treatTypeName + "' is not a subtype of: " + managedTypeClass.getName()); } return type; } return metamodel.managedType(managedTypeClass); }
public static ManagedType<?> getManagedType(EntityMetamodel metamodel, Class<?> managedTypeClass, String treatTypeName) { if (treatTypeName != null) { ManagedType<?> type = metamodel.managedType(treatTypeName); if (!managedTypeClass.isAssignableFrom(type.getJavaType())) { throw new IllegalArgumentException("Treat type '" + treatTypeName + "' is not a subtype of: " + managedTypeClass.getName()); } return type; } return metamodel.managedType(managedTypeClass); }
@SuppressWarnings({"unchecked"}) public SingularAttributeJoin(BlazeCriteriaBuilderImpl criteriaBuilder, Class<X> javaType, AbstractPath<Z> pathSource, SingularAttribute<? super Z, ?> joinAttribute, JoinType joinType) { super(criteriaBuilder, javaType, pathSource, joinAttribute, joinType); this.model = (Bindable<X>) (Attribute.PersistentAttributeType.EMBEDDED == joinAttribute .getPersistentAttributeType() ? joinAttribute : criteriaBuilder.getEntityMetamodel().managedType(javaType)); }
@SuppressWarnings({"unchecked"}) public SingularAttributeJoin(BlazeCriteriaBuilderImpl criteriaBuilder, Class<X> javaType, AbstractPath<Z> pathSource, SingularAttribute<? super Z, ?> joinAttribute, JoinType joinType) { super(criteriaBuilder, javaType, pathSource, joinAttribute, joinType); this.model = (Bindable<X>) (Attribute.PersistentAttributeType.EMBEDDED == joinAttribute .getPersistentAttributeType() ? joinAttribute : criteriaBuilder.getEntityMetamodel().managedType(javaType)); }
public static boolean isIndexedList(EntityMetamodel metamodel, ExpressionFactory expressionFactory, Class<?> entityClass, String mapping) { if (mapping == null || mapping.isEmpty()) { return false; } PathTargetResolvingExpressionVisitor visitor = new PathTargetResolvingExpressionVisitor(metamodel, metamodel.managedType(entityClass), null); expressionFactory.createSimpleExpression(mapping, false).accept(visitor); Map<Attribute<?, ?>, javax.persistence.metamodel.Type<?>> possibleTargets = visitor.getPossibleTargets(); Iterator<Map.Entry<Attribute<?, ?>, javax.persistence.metamodel.Type<?>>> iter = possibleTargets.entrySet().iterator(); // It must have one, otherwise a parse error would have been thrown already Map.Entry<Attribute<?, ?>, ?> targetEntry = iter.next(); boolean indexed = isIndexedList(targetEntry.getKey()); while (iter.hasNext()) { targetEntry = iter.next(); if (indexed != isIndexedList(targetEntry.getKey())) { throw new IllegalArgumentException("Inconclusive result on checking whether the expression [" + mapping + "] resolves to an indexed list on class [" + entityClass.getName() + "]."); } } return indexed; }
public static AttributeAccessor forEntityMapping(EntityViewManagerImpl evm, Class<?> entityClass, String mapping) { if (mapping.isEmpty()) { return new NestedAttributeAccessor(Collections.<AttributeAccessor>emptyList()); } EntityMetamodel entityMetamodel = evm.getMetamodel().getEntityMetamodel(); AttributePath path = evm.getJpaProvider().getJpaMetamodelAccessor().getBasicAttributePath(entityMetamodel, entityMetamodel.managedType(entityClass), mapping); List<Attribute<?, ?>> attributes = path.getAttributes(); if (attributes.size() == 1) { return forEntityAttribute(evm, entityClass, attributes.get(0), null); } List<AttributeAccessor> mappers = new ArrayList<>(attributes.size()); Class<?> targetClass = entityClass; for (int i = 0; i < attributes.size() - 1; i++) { javax.persistence.metamodel.Attribute<?, ?> attribute = attributes.get(i); Class<?> attributeClass = JpaMetamodelUtils.resolveFieldClass(targetClass, attribute); mappers.add(forEntityAttribute(evm, targetClass, attribute, attributeClass)); targetClass = attributeClass; } mappers.add(forEntityAttribute(evm, targetClass, attributes.get(attributes.size() - 1), null)); return new NestedAttributeAccessor(mappers); }
validateTypesCompatible(context.getEntityMetamodel().managedType(correlated), stripThisFromMapping(correlationResult), expressionType, elementType, true, !isCollection(), context, ExpressionLocation.CORRELATION_RESULT, getLocation());