@Override public void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo pui) { if (persistenceUnitProperties != null) { String puName = pui.getPersistenceUnitName() + "."; Set<String> keys = persistenceUnitProperties.keySet(); Properties props = pui.getProperties(); for (String key : keys) { if (key.startsWith(puName)){ String value = persistenceUnitProperties.get(key); String newKey = key.substring(puName.length()); if ("null".equalsIgnoreCase(value)){ props.remove(newKey); } else if (value != null && ! "".equals(value)) { props.put(newKey, value); } } } pui.setProperties(props); } }
pui.setProperties(newPU.getProperties()); } else { Properties props = newPU.getProperties();
/** * Post-process the persistence unit information. If we have seen this persistence * unit name before, merge any newly-defined classes in. Also, if any properties * are set on this post-processor, set them onto the target PersistenceUnitInfo */ @Override public synchronized void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo pui) { ValidationUtils.assertNotNull(pui, "persistenceUnitInfo cannot be null"); Set<String> classes = puiClasses.get(pui.getPersistenceUnitName()); if (classes == null) { classes = new LinkedHashSet<String>(); puiClasses.put(pui.getPersistenceUnitName(), classes); } pui.getManagedClassNames().addAll(classes); classes.addAll(pui.getManagedClassNames()); if (properties != null) pui.setProperties(properties); }