private void handleProperty(EntityType entityType, Class<?> cl, org.hibernate.mapping.Property p) throws NoSuchMethodException, ClassNotFoundException { Type propertyType = getType(cl, p.getName()); if (p.isComposite()) { Class<?> embeddedClass = Class.forName(propertyType.getFullName()); EntityType embeddedType = createEmbeddableType(embeddedClass); Iterator<?> properties = ((Component) p.getValue()).getPropertyIterator(); while (properties.hasNext()) { handleProperty( embeddedType, embeddedClass, (org.hibernate.mapping.Property) properties.next()); } propertyType = embeddedType; } else if (propertyType.getCategory() == TypeCategory.ENTITY) { propertyType = createEntityType(Class.forName(propertyType.getFullName())); } AnnotatedElement annotated = getAnnotatedElement(cl, p.getName()); Property property = createProperty(entityType, p.getName(), propertyType, annotated); entityType.addProperty(property); }
@SuppressWarnings("unchecked") @Before public void setUp() { // type Type typeModel = new SimpleType( TypeCategory.ENTITY, "com.mysema.query.DomainClass", "com.mysema.query", "DomainClass", false, false); type = new EntityType(typeModel); // property type.addProperty(new Property(type, "entityField", type, new String[0])); type.addProperty( new Property( type, "collection", new ClassType(TypeCategory.COLLECTION, Collection.class, typeModel), new String[0])); type.addProperty( new Property( type, "listField", new ClassType(TypeCategory.LIST, List.class, typeModel), new String[0])); type.addProperty( new Property( type, "setField", new ClassType(TypeCategory.SET, Set.class, typeModel), new String[0])); type.addProperty( new Property( type, "arrayField", new ClassType(TypeCategory.ARRAY, String[].class, typeModel), new String[0])); type.addProperty( new Property( type, "mapField", new ClassType(TypeCategory.MAP, List.class, typeModel, typeModel), new String[0])); type.addProperty( new Property( type, "superTypeField", new TypeExtends(new ClassType(TypeCategory.MAP, List.class, typeModel, typeModel)), new String[0])); type.addProperty( new Property( type, "extendsTypeField", new TypeSuper(new ClassType(TypeCategory.MAP, List.class, typeModel, typeModel)), new String[0])); for (Class<?> cl : Arrays.asList( Boolean.class, Comparable.class, Integer.class, Date.class, java.sql.Date.class, java.sql.Time.class)) { Type classType = new ClassType(TypeCategory.get(cl.getName()), cl); type.addProperty( new Property( type, StringUtils.uncapitalize(cl.getSimpleName()), classType, new String[0])); } // constructor Parameter firstName = new Parameter("firstName", new ClassType(TypeCategory.STRING, String.class)); Parameter lastName = new Parameter("lastName", new ClassType(TypeCategory.STRING, String.class)); type.addConstructor(new Constructor(Arrays.asList(firstName, lastName))); }