List of usage examples for org.hibernate.mapping MappedSuperclass getMappedClass
public Class getMappedClass()
From source file:com.mysema.query.jpa.codegen.HibernateDomainExporter.java
License:Apache License
private void collectTypes() throws IOException, XMLStreamException, ClassNotFoundException, SecurityException, NoSuchMethodException {/*from ww w . ja v a 2s . c om*/ // super classes Iterator<?> superClassMappings = configuration.getMappedSuperclassMappings(); while (superClassMappings.hasNext()) { MappedSuperclass msc = (MappedSuperclass) superClassMappings.next(); EntityType entityType = createSuperType(msc.getMappedClass()); if (msc.getDeclaredIdentifierProperty() != null) { handleProperty(entityType, msc.getMappedClass(), msc.getDeclaredIdentifierProperty()); } Iterator<?> properties = msc.getDeclaredPropertyIterator(); while (properties.hasNext()) { handleProperty(entityType, msc.getMappedClass(), (org.hibernate.mapping.Property) properties.next()); } } // entity classes Iterator<?> classMappings = configuration.getClassMappings(); while (classMappings.hasNext()) { PersistentClass pc = (PersistentClass) classMappings.next(); EntityType entityType = createEntityType(pc.getMappedClass()); if (pc.getDeclaredIdentifierProperty() != null) { handleProperty(entityType, pc.getMappedClass(), pc.getDeclaredIdentifierProperty()); } else if (!pc.isInherited() && pc.hasIdentifierProperty()) { logger.info(entityType.toString() + pc.getIdentifierProperty()); handleProperty(entityType, pc.getMappedClass(), pc.getIdentifierProperty()); } else if (pc.getIdentifier() != null) { KeyValue identifier = pc.getIdentifier(); if (identifier instanceof Component) { Component component = (Component) identifier; Iterator<?> properties = component.getPropertyIterator(); if (component.isEmbedded()) { while (properties.hasNext()) { handleProperty(entityType, pc.getMappedClass(), (org.hibernate.mapping.Property) properties.next()); } } else { String name = component.getNodeName(); Class<?> clazz = component.getType().getReturnedClass(); Type propertyType = getType(pc.getMappedClass(), clazz, name); AnnotatedElement annotated = getAnnotatedElement(pc.getMappedClass(), name); Property property = createProperty(entityType, name, propertyType, annotated); entityType.addProperty(property); // handle component properties EntityType embeddedType = createEmbeddableType(propertyType); while (properties.hasNext()) { handleProperty(embeddedType, clazz, (org.hibernate.mapping.Property) properties.next()); } } } // TODO handle other KeyValue subclasses such as Any, DependentValue and ToOne } Iterator<?> properties = pc.getDeclaredPropertyIterator(); while (properties.hasNext()) { handleProperty(entityType, pc.getMappedClass(), (org.hibernate.mapping.Property) properties.next()); } } // go through supertypes Set<Supertype> additions = Sets.newHashSet(); for (Map.Entry<String, EntityType> entry : allTypes.entrySet()) { EntityType entityType = entry.getValue(); if (entityType.getSuperType() != null && !allTypes.containsKey(entityType.getSuperType().getType().getFullName())) { additions.add(entityType.getSuperType()); } } for (Supertype type : additions) { type.setEntityType(createEntityType(type.getType(), superTypes)); } }
From source file:com.querydsl.jpa.codegen.HibernateDomainExporter.java
License:Apache License
@Override protected void collectTypes() throws IOException, XMLStreamException, ClassNotFoundException, NoSuchMethodException { // super classes Iterator<?> superClassMappings = configuration.getMappedSuperclassMappings(); while (superClassMappings.hasNext()) { MappedSuperclass msc = (MappedSuperclass) superClassMappings.next(); EntityType entityType = createSuperType(msc.getMappedClass()); if (msc.getDeclaredIdentifierProperty() != null) { handleProperty(entityType, msc.getMappedClass(), msc.getDeclaredIdentifierProperty()); }//from ww w . j av a 2s .c om Iterator<?> properties = msc.getDeclaredPropertyIterator(); while (properties.hasNext()) { handleProperty(entityType, msc.getMappedClass(), (org.hibernate.mapping.Property) properties.next()); } } // entity classes Iterator<?> classMappings = configuration.getClassMappings(); while (classMappings.hasNext()) { PersistentClass pc = (PersistentClass) classMappings.next(); EntityType entityType = createEntityType(pc.getMappedClass()); if (pc.getDeclaredIdentifierProperty() != null) { handleProperty(entityType, pc.getMappedClass(), pc.getDeclaredIdentifierProperty()); } else if (!pc.isInherited() && pc.hasIdentifierProperty()) { logger.info(entityType.toString() + pc.getIdentifierProperty()); handleProperty(entityType, pc.getMappedClass(), pc.getIdentifierProperty()); } else if (pc.getIdentifier() != null) { KeyValue identifier = pc.getIdentifier(); if (identifier instanceof Component) { Component component = (Component) identifier; Iterator<?> properties = component.getPropertyIterator(); if (component.isEmbedded()) { while (properties.hasNext()) { handleProperty(entityType, pc.getMappedClass(), (org.hibernate.mapping.Property) properties.next()); } } else { String name = component.getNodeName(); Class<?> clazz = component.getType().getReturnedClass(); Type propertyType = getType(pc.getMappedClass(), clazz, name); AnnotatedElement annotated = getAnnotatedElement(pc.getMappedClass(), name); Property property = createProperty(entityType, name, propertyType, annotated); entityType.addProperty(property); // handle component properties EntityType embeddedType = createEmbeddableType(propertyType); while (properties.hasNext()) { handleProperty(embeddedType, clazz, (org.hibernate.mapping.Property) properties.next()); } } } // TODO handle other KeyValue subclasses such as Any, DependentValue and ToOne } Iterator<?> properties = pc.getDeclaredPropertyIterator(); while (properties.hasNext()) { handleProperty(entityType, pc.getMappedClass(), (org.hibernate.mapping.Property) properties.next()); } } }