List of usage examples for javax.persistence.metamodel EntityType getPluralAttributes
Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes();
From source file:ru.savvy.jpafilterbuilder.FilterCriteriaBuilder.java
/** * This clumsy code is just to get the class of plural attribute mapping * * @param et//from w ww . j a v a 2 s . c om * @param fieldName * @return */ private Class<?> getPluralJavaType(EntityType<?> et, String fieldName) { for (PluralAttribute pa : et.getPluralAttributes()) { if (pa.getName().equals(fieldName)) { switch (pa.getCollectionType()) { case COLLECTION: return et.getCollection(fieldName).getElementType().getJavaType(); case LIST: return et.getList(fieldName).getElementType().getJavaType(); case SET: return et.getSet(fieldName).getElementType().getJavaType(); case MAP: throw new UnsupportedOperationException("Entity Map mapping unsupported for entity: " + et.getName() + " field name: " + fieldName); } } } throw new IllegalArgumentException( "Field " + fieldName + " of entity " + et.getName() + " is not a plural attribute"); }