openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pinaki Poddar (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OPENJPA-1803) Unwrap EntityManager to Connection
Date Wed, 13 Jul 2011 01:10:59 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-1803?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13064271#comment-13064271
] 

Pinaki Poddar commented on OPENJPA-1803:
----------------------------------------

+ if (cls.isAssignableFrom(Connection.class)) {
+                return (T) getConnection();
+            }

This leaves the code vulnerable. The code should check that the return value of  this.getConnection()
is indeed a java.sql.Connection.
OpenJPA EntityManager can operate at this level with datastore connections that are *not*
 java.sql.Connection.



> Unwrap EntityManager to Connection
> ----------------------------------
>
>                 Key: OPENJPA-1803
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1803
>             Project: OpenJPA
>          Issue Type: Improvement
>          Components: competitive, jpa
>    Affects Versions: 2.0.1
>            Reporter: Harald Wellmann
>            Assignee: Rick Curtis
>             Fix For: 2.2.0
>
>         Attachments: OPENJPA-1803.patch
>
>
> This is currently the recommended way to access the javax.sql.Connection underlying an
EntityManager:
>         OpenJPAEntityManager oem = OpenJPAPersistence.cast(em);
>         Connection con = (Connection) oem.getConnection();
> It would be more convenient to simply write
>         Connection con = em.unwrap(Connection.class);
> That way, the client needing to access the Connection only depends on the javax.persistence
API and not on org.apache.openjpa.*.
> I believe the JPA 2.0 spec neither mandates nor forbids this functionality. It is supported
by Eclipselink 2.x.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message