private static String defaultPersistenceUnitName(String persistenceUnitName, PersistenceUnitMetadataHolder holder) {
        if ((persistenceUnitName == null || persistenceUnitName.length() == 0)) {
            for (PersistenceUnitMetadata persistenceUnit : holder.getPersistenceUnits()) {
                String defaultPU = persistenceUnit.getProperties().getProperty(Configuration.JPA_DEFAULT_PERSISTENCE_UNIT);
                if(Boolean.TRUE.toString().equals(defaultPU)) {
                    persistenceUnitName = persistenceUnit.getPersistenceUnitName();
                }
            }
        }
        return persistenceUnitName;
    }
private static String defaultPersistenceUnitName(String persistenceUnitName, PersistenceUnitMetadataHolder holder) {
        if ((persistenceUnitName == null || persistenceUnitName.length() == 0)) {
            for (PersistenceUnitMetadata persistenceUnit : holder.getPersistenceUnits()) {
                String defaultPU = persistenceUnit.getProperties().getProperty(Configuration.JPA_DEFAULT_PERSISTENCE_UNIT);
                if(Boolean.TRUE.toString().equals(defaultPU)) {
                    persistenceUnitName = persistenceUnit.getPersistenceUnitName();
                }
            }
        }
        return persistenceUnitName;
    }
private static String defaultPersistenceUnitName ( String persistenceUnitName , PersistenceUnitMetadataHolder holder ) { if ( ( persistenceUnitName == null || persistenceUnitName . length ( ) == 0 ) ) { for ( PersistenceUnitMetadata persistenceUnit : holder . getPersistenceUnits ( ) ) { String defaultPU = persistenceUnit . getProperties ( ) . getProperty ( Configuration . JPA_DEFAULT_PERSISTENCE_UNIT ) ; if ( Boolean . TRUE . toString ( ) . equals ( defaultPU ) ) { persistenceUnitName = persistenceUnit . getPersistenceUnitName ( ) ; } } } return persistenceUnitName ; }
if no persistence unit name is specified, return name of default persistence unit

@param persistenceUnitName that was specified to be used (null means to use the default persistence unit)
@param holder
@return
if no persistence unit name is specified return name of default persistence unit