* @return
*/
private EntityType buildEntityType(SessionFactory sessionFactory, String entityName) {
EntityType entityType = (EntityType) entityTypes.get(entityName);
if (null == entityType) {
ClassMetadata cm = sessionFactory.getClassMetadata(entityName);
if (null == cm) {
logger.error("Cannot find ClassMetadata for {}", entityName);
return null;
}
entityType = new EntityType();
entityType.setEntityName(cm.getEntityName());
entityType.setIdPropertyName(cm.getIdentifierPropertyName());
entityType.setEntityClass(cm.getMappedClass(EntityMode.POJO));
entityTypes.put(cm.getEntityName(), entityType);
Map<String, Type> propertyTypes = entityType.getPropertyTypes();
String[] ps = cm.getPropertyNames();
for (int i = 0; i < ps.length; i++) {
org.hibernate.type.Type type = cm.getPropertyType(ps[i]);
if (type.isEntityType()) {
propertyTypes.put(ps[i], buildEntityType(sessionFactory, type.getName()));
} else if (type.isComponentType()) {
propertyTypes.put(ps[i], buildComponentType(sessionFactory, entityName, ps[i]));
} else if (type.isCollectionType()) {