[
https://issues.apache.org/jira/browse/OPENJPA-2393?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13677499#comment-13677499
]
Chris Wolf commented on OPENJPA-2393:
-------------------------------------
The code at:
http://openjpa.apache.org/builds/2.2.1/apache-openjpa/docs/manual.html#ref_guide_dbsetup_conn_from_factory_jpa
Uses deprecated APIs. The deprecation warnings can be eliminated as follows:
OpenJPAEntityManagerFactorySPI spiEmf = (OpenJPAEntityManagerFactorySPI)
OpenJPAPersistence.cast(emf);
OpenJPAConfiguration conf = spiEmf.getConfiguration();
DataSource dataSource = (DataSource) conf.getConnectionFactory();
conn = dataSource.getConnection();
The above code only works in a managed environment. For a standalone app,
dataSource.getConnection();
throws "Invalid user or password".
> Can only get java.sql.Connection from EMF's DataSource in container-managed
> env.
> --------------------------------------------------------------------------------
>
> Key: OPENJPA-2393
> URL: https://issues.apache.org/jira/browse/OPENJPA-2393
> Project: OpenJPA
> Issue Type: Bug
> Components: jpa
> Affects Versions: 2.2.1
> Environment: Windows-7/64bit, Oracle/Sun JRE-1.6.x, JBoss-6.1.0 and
> standalone app (JSE)
> Reporter: Chris Wolf
> Priority: Minor
> Labels: OpenJPAConfiguration
>
> The documentation describes how to obtain a plain java.sql.Connection from
> the EntityManagerFactory, but it only works in a managed container
> environment (JEE). The page I'm referring to is here:
> http://openjpa.apache.org/builds/2.2.1/apache-openjpa/docs/manual.html#ref_guide_dbsetup_conn_from_factory_jpa
--
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