[jboss-jira] [JBoss JIRA] (WFLY-2212) Update JPA subsystem to use default datasource

Scott Marlow (JIRA) jira-events at lists.jboss.org
Sat Oct 19 07:29:02 EDT 2013


    [ https://issues.jboss.org/browse/WFLY-2212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12823312#comment-12823312 ] 

Scott Marlow commented on WFLY-2212:
------------------------------------

In JPA 2.0, the container may or may not be able to supply a default datasource.  If applications want a default datasource to be used, they just configure the jpa section in standalone.xml (or whichever config they are using).  

In the OGM case, the OGM persistence provider (strictly) throws a deployment error if a data-source is supplied.  OGM doesn't use a data-source so throwing an deployment is fine as long as the JPA container doesn't supply one.

Thanks for the patch [~emmartins].  If you can also add the following method to org.jboss.as.jpa.config.Configuration (at the bottom is fine).   Also add a constant (something like) JPA_ALLOW_DEFAULT_DATA_SOURCE_USE set to "wildfly.jpa.allowdefaultdatasourceuse" (defaults to true but can be overridden to false in a persistence unit definition).  I think the focus is on tck now but we can see if your patch is accepted for WF8, if not it can be considered for WF9.  Another change that is needed is to pick one of JPA unit tests and remove the datasource from the persistence.xml (org.jboss.as.test.integration.jpa.webtxem.WebJPATestCase or pick any one).   Other changes are below.

{code}
    /**
     * Determine the default data-source should be used
     *
     * @param pu
     * @return true if the default data-source should be used
     */
    public static boolean allowDefaultDataSourceUse(PersistenceUnitMetadata pu) {
        boolean result = true;
        if (pu.getProperties().containsKey(Configuration.JPA_ALLOW_DEFAULT_DATA_SOURCE_USE)) {
            result = Boolean.parseBoolean(pu.getProperties().getProperty(Configuration.JPA_ALLOW_DEFAULT_DATA_SOURCE_USE));
        }
        return result;
    }
{code}

In PersistenceUnitServiceHandler, change to:
{code}
boolean useDefaultDataSource = Configuration.allowDefaultDataSourceUse(pu);
{code}
                
> Update JPA subsystem to use default datasource
> ----------------------------------------------
>
>                 Key: WFLY-2212
>                 URL: https://issues.jboss.org/browse/WFLY-2212
>             Project: WildFly
>          Issue Type: Task
>          Components: JPA / Hibernate
>            Reporter: Scott Marlow
>            Assignee: Scott Marlow
>             Fix For: 8.0.0.CR1
>
>
> See comments in WFLY-2027 before starting the work on this jira...

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list