use of org.hibernate.jpamodelgen.xml.jaxb.EntityMappings in project hibernate-orm by hibernate.
the class JpaDescriptorParser method loadEntityMappings.
private void loadEntityMappings(Collection<String> mappingFileNames) {
for (String mappingFile : mappingFileNames) {
InputStream stream = xmlParserHelper.getInputStreamForResource(mappingFile);
if (stream == null) {
continue;
}
EntityMappings mapping = null;
try {
Schema schema = xmlParserHelper.getSchema(ORM_SCHEMA);
mapping = xmlParserHelper.getJaxbRoot(stream, EntityMappings.class, schema);
} catch (XmlParsingException e) {
context.logMessage(Diagnostic.Kind.WARNING, "Unable to parse " + mappingFile + ": " + e.getMessage());
}
if (mapping != null) {
entityMappings.add(mapping);
}
try {
stream.close();
} catch (IOException e) {
// eat it
}
}
}
use of org.hibernate.jpamodelgen.xml.jaxb.EntityMappings in project hibernate-orm by hibernate.
the class JpaDescriptorParser method determineAnnotationAccessTypes.
private void determineAnnotationAccessTypes() {
for (EntityMappings mappings : entityMappings) {
String fqcn;
String packageName = mappings.getPackage();
for (Entity entity : mappings.getEntity()) {
String name = entity.getClazz();
fqcn = StringUtil.determineFullyQualifiedClassName(packageName, name);
TypeElement element = context.getTypeElementForFullyQualifiedName(fqcn);
if (element != null) {
TypeUtils.determineAccessTypeForHierarchy(element, context);
}
}
for (org.hibernate.jpamodelgen.xml.jaxb.MappedSuperclass mappedSuperClass : mappings.getMappedSuperclass()) {
String name = mappedSuperClass.getClazz();
fqcn = StringUtil.determineFullyQualifiedClassName(packageName, name);
TypeElement element = context.getTypeElementForFullyQualifiedName(fqcn);
if (element != null) {
TypeUtils.determineAccessTypeForHierarchy(element, context);
}
}
}
}
use of org.hibernate.jpamodelgen.xml.jaxb.EntityMappings in project hibernate-orm by hibernate.
the class JpaDescriptorParser method determineXmlAccessTypes.
private void determineXmlAccessTypes() {
for (EntityMappings mappings : entityMappings) {
String fqcn;
String packageName = mappings.getPackage();
AccessType defaultAccessType = determineEntityAccessType(mappings);
for (Entity entity : mappings.getEntity()) {
String name = entity.getClazz();
fqcn = StringUtil.determineFullyQualifiedClassName(packageName, name);
AccessType explicitAccessType = null;
org.hibernate.jpamodelgen.xml.jaxb.AccessType type = entity.getAccess();
if (type != null) {
explicitAccessType = mapXmlAccessTypeToJpaAccessType(type);
}
AccessTypeInformation accessInfo = new AccessTypeInformation(fqcn, explicitAccessType, defaultAccessType);
context.addAccessTypeInformation(fqcn, accessInfo);
}
for (org.hibernate.jpamodelgen.xml.jaxb.MappedSuperclass mappedSuperClass : mappings.getMappedSuperclass()) {
String name = mappedSuperClass.getClazz();
fqcn = StringUtil.determineFullyQualifiedClassName(packageName, name);
AccessType explicitAccessType = null;
org.hibernate.jpamodelgen.xml.jaxb.AccessType type = mappedSuperClass.getAccess();
if (type != null) {
explicitAccessType = mapXmlAccessTypeToJpaAccessType(type);
}
AccessTypeInformation accessInfo = new AccessTypeInformation(fqcn, explicitAccessType, defaultAccessType);
context.addAccessTypeInformation(fqcn, accessInfo);
}
for (org.hibernate.jpamodelgen.xml.jaxb.Embeddable embeddable : mappings.getEmbeddable()) {
String name = embeddable.getClazz();
fqcn = StringUtil.determineFullyQualifiedClassName(packageName, name);
AccessType explicitAccessType = null;
org.hibernate.jpamodelgen.xml.jaxb.AccessType type = embeddable.getAccess();
if (type != null) {
explicitAccessType = mapXmlAccessTypeToJpaAccessType(type);
}
AccessTypeInformation accessInfo = new AccessTypeInformation(fqcn, explicitAccessType, defaultAccessType);
context.addAccessTypeInformation(fqcn, accessInfo);
}
}
}
use of org.hibernate.jpamodelgen.xml.jaxb.EntityMappings in project hibernate-orm by hibernate.
the class JpaDescriptorParser method parseXml.
public void parseXml() {
Collection<String> mappingFileNames = determineMappingFileNames();
if (context.doLazyXmlParsing() && mappingFilesUnchanged(mappingFileNames)) {
return;
}
loadEntityMappings(mappingFileNames);
determineDefaultAccessTypeAndMetaCompleteness();
determineXmlAccessTypes();
if (!context.isFullyXmlConfigured()) {
// need to take annotations into consideration, since they can override xml settings
// we have to at least determine whether any of the xml configured entities is influenced by annotations
determineAnnotationAccessTypes();
}
for (EntityMappings mappings : entityMappings) {
String defaultPackageName = mappings.getPackage();
parseEntities(mappings.getEntity(), defaultPackageName);
parseEmbeddable(mappings.getEmbeddable(), defaultPackageName);
parseMappedSuperClass(mappings.getMappedSuperclass(), defaultPackageName);
}
}
Aggregations