<!-- Zeichensatz -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Verwendete Versionen -->
- <hibernate.version>5.2.4.Final</hibernate.version>
- <hibernate-validator.version>5.3.1.Final</hibernate-validator.version>
+ <hibernate.version>5.2.10.Final</hibernate.version>
+ <hibernate-validator.version>5.4.1.Final</hibernate-validator.version>
<el-api.version>3.0.0</el-api.version>
<maven.version>3.3.3</maven.version>
<maven-plugin-log4j.version>1.0.1</maven-plugin-log4j.version>
LoadedConfig config = loadConfig(configLoader);
if (config != null)
properties.putAll(config.getConfigurationValues());
- ParsedPersistenceXmlDescriptor unit =
- loadPersistenceUnit(classLoaderService, properties);
+ ParsedPersistenceXmlDescriptor unit = loadPersistenceUnit(properties);
if (unit != null)
properties.putAll(unit.getProperties());
}
private ParsedPersistenceXmlDescriptor loadPersistenceUnit(
- ClassLoaderService classLoaderService,
Properties properties
)
throws
MojoFailureException
{
- PersistenceXmlParser parser =
- new PersistenceXmlParser(
- classLoaderService,
- PersistenceUnitTransactionType.RESOURCE_LOCAL
- );
-
- Map<String, ParsedPersistenceXmlDescriptor> units =
- parser.doResolve(properties);
+ List<ParsedPersistenceXmlDescriptor> units =
+ PersistenceXmlParser.locatePersistenceUnits(properties);
if (persistenceUnit == null)
{
- Iterator<String> names = units.keySet().iterator();
- if (!names.hasNext())
+ if (units.isEmpty())
{
getLog().info("Found no META-INF/persistence.xml.");
return null;
}
- String name = names.next();
- if (!names.hasNext())
+ if (units.size() == 1)
{
- getLog().info("Using persistence-unit " + name);
- return units.get(name);
+ ParsedPersistenceXmlDescriptor descriptor = units.get(0);
+ getLog().info("Using persistence-unit " + descriptor.getName());
+ return descriptor;
}
StringBuilder builder = new StringBuilder();
builder.append("No name provided and multiple persistence units found: ");
- builder.append(name);
- while(names.hasNext())
+ Iterator<ParsedPersistenceXmlDescriptor> it = units.iterator();
+ while(it.hasNext())
{
- builder.append(", ");
- builder.append(names.next());
+ builder.append(it.next().getName());
+ if (it.hasNext())
+ builder.append(", ");
}
builder.append('.');
throw new MojoFailureException(builder.toString());
}
- if (units.containsKey(persistenceUnit))
+ Iterator<ParsedPersistenceXmlDescriptor> it = units.iterator();
+ while(it.hasNext())
{
- getLog().info("Using configured persistence-unit " + persistenceUnit);
- return units.get(persistenceUnit);
+ ParsedPersistenceXmlDescriptor descriptor = it.next();
+ if (descriptor.getName().equals(persistenceUnit))
+ {
+ getLog().info("Using configured persistence-unit " + persistenceUnit);
+ return descriptor;
+ }
}
throw new MojoFailureException("Could not find persistence-unit " + persistenceUnit);