Bug 396885 - JPAInitializer does not handle javax.persistence.provider property override
Summary: JPAInitializer does not handle javax.persistence.provider property override
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P2 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-18 18:24 EST by Doug Clarke CLA
Modified: 2022-06-09 10:22 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Doug Clarke CLA 2012-12-18 18:24:52 EST
The org.eclipse.persistence.internal.jpa.deployment.JPAInitializer

    protected SEPersistenceUnitInfo findPersistenceUnitInfoInArchive(String puName, Archive archive, Map m){
        Iterator<SEPersistenceUnitInfo> persistenceUnits = PersistenceUnitProcessor.getPersistenceUnits(archive, initializationClassloader).iterator();
        while (persistenceUnits.hasNext()) {
            SEPersistenceUnitInfo persistenceUnitInfo = persistenceUnits.next();
            if(isPersistenceProviderSupported(persistenceUnitInfo.getPersistenceProviderClassName()) &&  persistenceUnitInfo.getPersistenceUnitName().equals(puName)) {
                return persistenceUnitInfo;
            }
        }
        return null;
    }

This method should allow the javax.persistence.provider property in the map to override the value specified in the persistence.xml.

Within the while loop the code should look like:

SEPersistenceUnitInfo persistenceUnitInfo = persistenceUnits.next();

String providerClassName = persistenceUnitInfo.getPersistenceProviderClassName();

if (m.containsKey("javax.persistence.provider")) {
    providerClassName  = (String) m.get("javax.persistence.provider");
}
 
           if(isPersistenceProviderSupported(providerClassName ) &&  persistenceUnitInfo.getPersistenceUnitName().equals(puName)) {
                return persistenceUnitInfo;
Comment 1 Eclipse Webmaster CLA 2022-06-09 10:22:54 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink