List of usage examples for org.hibernate.persister.entity AbstractEntityPersister getEntityType
public EntityType getEntityType()
From source file:org.nextframework.persistence.PersistenceUtils.java
License:Apache License
public static Class<?> getPropertyAssociationType(SessionFactory sessionFactory, Class<?> clazz, String property) {/*w ww . j a v a2s . co m*/ Class<?> result = null; ClassMetadata classMetadata = getClassMetadata(clazz, sessionFactory); if (classMetadata == null) { throw new PersistenceException("Class " + clazz.getName() + " is not mapped. "); } org.hibernate.type.Type propertyType = classMetadata.getPropertyType(property); if (propertyType instanceof AssociationType) { AssociationType associationType = (AssociationType) propertyType; String associatedEntityName = associationType .getAssociatedEntityName((SessionFactoryImplementor) sessionFactory); AbstractEntityPersister abstractEntityPersister = (AbstractEntityPersister) sessionFactory .getClassMetadata(associatedEntityName); result = abstractEntityPersister.getEntityType().getReturnedClass(); } else { throw new PersistenceException("Property \"" + property + "\" of " + clazz + " is not an association type (i.e. ManyToOne, OneToMany, AnyType, etc)"); } return result; }