use of javax.persistence.metamodel.PluralAttribute 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 Primitives.wrap(attribute.getJavaType());
}
} catch (IllegalArgumentException e) {
return null;
}
}
use of javax.persistence.metamodel.PluralAttribute in project hibernate-orm by hibernate.
the class AbstractManagedType method getBuilder.
public Builder<X> getBuilder() {
if (locked) {
throw new IllegalStateException("Type has been locked");
}
return new Builder<X>() {
@Override
@SuppressWarnings("unchecked")
public void addAttribute(Attribute<X, ?> attribute) {
declaredAttributes.put(attribute.getName(), attribute);
final Bindable.BindableType bindableType = ((Bindable) attribute).getBindableType();
switch(bindableType) {
case SINGULAR_ATTRIBUTE:
{
declaredSingularAttributes.put(attribute.getName(), (SingularAttribute<X, ?>) attribute);
break;
}
case PLURAL_ATTRIBUTE:
{
declaredPluralAttributes.put(attribute.getName(), (PluralAttribute<X, ?, ?>) attribute);
break;
}
default:
{
throw new AssertionFailure("unknown bindable type: " + bindableType);
}
}
}
};
}
use of javax.persistence.metamodel.PluralAttribute in project hibernate-orm by hibernate.
the class AbstractFromImpl method joinCollection.
@Override
@SuppressWarnings({ "unchecked" })
public <X, Y> CollectionJoin<X, Y> joinCollection(String attributeName, JoinType jt) {
final Attribute<X, ?> attribute = (Attribute<X, ?>) locateAttribute(attributeName);
if (!attribute.isCollection()) {
throw new IllegalArgumentException("Requested attribute was not a collection");
}
final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
if (!PluralAttribute.CollectionType.COLLECTION.equals(pluralAttribute.getCollectionType())) {
throw new IllegalArgumentException("Requested attribute was not a collection");
}
return (CollectionJoin<X, Y>) join((CollectionAttribute) attribute, jt);
}
use of javax.persistence.metamodel.PluralAttribute in project hibernate-orm by hibernate.
the class AbstractFromImpl method joinSet.
@Override
@SuppressWarnings({ "unchecked" })
public <X, Y> SetJoin<X, Y> joinSet(String attributeName, JoinType jt) {
final Attribute<X, ?> attribute = (Attribute<X, ?>) locateAttribute(attributeName);
if (!attribute.isCollection()) {
throw new IllegalArgumentException("Requested attribute was not a set");
}
final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
if (!PluralAttribute.CollectionType.SET.equals(pluralAttribute.getCollectionType())) {
throw new IllegalArgumentException("Requested attribute was not a set");
}
return (SetJoin<X, Y>) join((SetAttribute) attribute, jt);
}
use of javax.persistence.metamodel.PluralAttribute 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);
}
Aggregations