use of org.jipijapa.plugin.spi.PersistenceUnitMetadata in project wildfly by wildfly.
the class PersistenceUnitSearch method resolvePersistenceUnitSupplier.
public static PersistenceUnitMetadata resolvePersistenceUnitSupplier(DeploymentUnit deploymentUnit, String persistenceUnitName) {
if (traceEnabled) {
ROOT_LOGGER.tracef("pu search for name '%s' inside of %s", persistenceUnitName, deploymentUnit.getName());
}
int scopeSeparatorCharacter = (persistenceUnitName == null ? -1 : persistenceUnitName.indexOf('#'));
if (scopeSeparatorCharacter != -1) {
final String path = persistenceUnitName.substring(0, scopeSeparatorCharacter);
final String name = persistenceUnitName.substring(scopeSeparatorCharacter + 1);
PersistenceUnitMetadata pu = getPersistenceUnit(deploymentUnit, path, name);
if (traceEnabled) {
ROOT_LOGGER.tracef("pu search found %s", pu.getScopedPersistenceUnitName());
}
return pu;
} else {
PersistenceUnitMetadata name = findPersistenceUnitSupplier(deploymentUnit, persistenceUnitName);
if (traceEnabled && name != null) {
ROOT_LOGGER.tracef("pu search found %s", name.getScopedPersistenceUnitName());
}
return name;
}
}
use of org.jipijapa.plugin.spi.PersistenceUnitMetadata in project wildfly by wildfly.
the class PersistenceUnitSearch method ambiguousPUError.
private static void ambiguousPUError(DeploymentUnit unit, String persistenceUnitName, PersistenceUnitMetadataHolder holder) {
if (holder.getPersistenceUnits().size() > 1 && (persistenceUnitName == null || persistenceUnitName.length() == 0)) {
int numberOfDefaultPersistenceUnits = 0;
// get number of persistence units that are marked as default
for (PersistenceUnitMetadata persistenceUnit : holder.getPersistenceUnits()) {
String defaultPU = persistenceUnit.getProperties().getProperty(Configuration.JPA_DEFAULT_PERSISTENCE_UNIT);
if (Boolean.TRUE.toString().equals(defaultPU)) {
numberOfDefaultPersistenceUnits++;
}
}
ROOT_LOGGER.tracef("checking for ambiguous persistence unit injection error, " + "number of persistence units marked default (%s) = %d", Configuration.JPA_DEFAULT_PERSISTENCE_UNIT, numberOfDefaultPersistenceUnits);
// don't throw an error if there is exactly one default persistence unit
if (numberOfDefaultPersistenceUnits != 1) {
// AS7-2275 no unitName and there is more than one persistence unit;
throw JpaLogger.ROOT_LOGGER.noPUnitNameSpecifiedAndMultiplePersistenceUnits(holder.getPersistenceUnits().size(), unit);
}
}
}
Aggregations