Issue Details (XML | Word | Printable)

Key: JDO-452
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Craig Russell
Reporter: Michelle Caisse
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JDO

Provide interfaces that extend both JDO and JPA

Created: 11/Dec/06 03:47 AM   Updated: 20/Sep/07 05:27 PM
Return to search
Component/s: api2
Affects Version/s: JDO 2 final
Fix Version/s: JDO 2 maintenance release 1

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works jdo-452.patch 2007-09-08 05:33 PM Craig Russell 7 kB
Text File Licensed for inclusion in ASF works jdo-452.patch 2007-09-07 09:18 PM Craig Russell 5 kB

Resolution Date: 20/Sep/07 05:27 PM


 Description  « Hide
Provide interfaces that extend both JDO and JPA in order to make it easier to migrate applications from JDO to JPA.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Craig Russell added a comment - 07/Sep/07 09:18 PM
Please review this patch. It adds two interfaces, JDOEntityManager that extends javax.persistence.EntityManager and javax.jdo.PersistenceManager; and JDOEntityManagerFactory that extends javax.persistence.EntityManagerFactory and javax.jdo.PersistenceManagerFactory.

It also updates the manifest for OSGi and the maven dependency (uses an Apache version of the Persistence jar file).

Note that the API2.MF file had the line endings changed so the diff is bigger than the change (which is only adding one line to import the javax.persistence package).

Craig Russell added a comment - 08/Sep/07 05:33 PM
I've updated the interfaces to override those methods that return PersistenceManager or PersistenceManagerFactory to return the more specific type.

Ilan Kirsh added a comment - 08/Sep/07 06:26 PM
Looks good.

I see that JDOEntityTransaction is not defined, but the following should be good enough:
  ((JDOEntityManager)em).currentTransaction().setOptimistic(false);

Do we need a method like em.getDelegate() but in the other direction, to get an EntityManager from a PersistenceManager proxy?

Craig Russell added a comment - 08/Sep/07 10:35 PM
> I see that JDOEntityTransaction is not defined,

The JDO Transaction is already a strict superset of EntityTransaction. To provide for a future EntityTransaction that includes more methods than are available in JDO Transaction, we could create a JDOEntityTransaction. But we could as easily add the new method directly to JDO Transaction.

> but the following should be good enough:
> ((JDOEntityManager)em).currentTransaction().setOptimistic(false);

I'm not clear which case this is. If you need to setOptimistic, you need either a PersistenceManager or a JDOEntityManager from which to get the currentTransaction. If all you have is an EntityManager (that doesn't implement PersistenceManager or JDOEntityManager), you can't cast it. If you have a JDOEntityManager, you don't need to cast it.

>Do we need a method like em.getDelegate() but in the other direction, to get an EntityManager from a PersistenceManager proxy?

I've changed the return type of JDOEntityManagerFactory.getPersistenceManagerProxy to return JDOEntityManager. Is this enough?

Ilan Kirsh added a comment - 08/Sep/07 10:55 PM
In the case above I assumed that em is a JDOEntityManager of course, but is referenced and used as an EntityManager where possible. Cast to JDOEntityManager is done only when an extension of JDO that is not supported in JPA is needed. Anyway, this should work well with the new interfaces.

Regarding the proxy, I didn't notice this before it but generating only JDOEntityManager proxies by JDOEntityManagerFactory seems as an elegant solution.

Craig Russell added a comment - 09/Sep/07 12:42 AM
> In the case above I assumed that em is a JDOEntityManager of course, but is referenced and used as an EntityManager where possible. Cast to JDOEntityManager is done only when an extension of JDO that is not supported in JPA is needed. Anyway, this should work well with the new interfaces.

Ah, makes sense now. Thanks for the clarification.

Craig Russell added a comment - 20/Sep/07 05:27 PM
svn commit -m "JDO-452 Add JDOEntityManager and JDOEntityManagerFactory" api2/project.xml api2/API2.MF api2/src/java/javax/jdo/JDOEntityManager.java api2/src/java/javax/jdo/JDOEntityManagerFactory.java
Sending api2/API2.MF
Sending api2/project.xml
Adding api2/src/java/javax/jdo/JDOEntityManager.java
Adding api2/src/java/javax/jdo/JDOEntityManagerFactory.java
Transmitting file data ....
Committed revision 577824.