JDO
  1. JDO
  2. JDO-452

Provide interfaces that extend both JDO and JPA

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JDO 2 final (2.0)
    • Component/s: api
    • Labels:
      None

      Description

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

      1. jdo-452.patch
        5 kB
        Craig L Russell
      2. jdo-452.patch
        7 kB
        Craig L Russell

        Activity

        Hide
        Craig L Russell added a comment -

        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).

        Show
        Craig L Russell added a comment - 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).
        Hide
        Craig L Russell added a comment -

        I've updated the interfaces to override those methods that return PersistenceManager or PersistenceManagerFactory to return the more specific type.

        Show
        Craig L Russell added a comment - I've updated the interfaces to override those methods that return PersistenceManager or PersistenceManagerFactory to return the more specific type.
        Hide
        Ilan Kirsh added a comment -

        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?

        Show
        Ilan Kirsh added a comment - 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?
        Hide
        Craig L Russell added a comment -

        > 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?

        Show
        Craig L Russell added a comment - > 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?
        Hide
        Ilan Kirsh added a comment -

        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.

        Show
        Ilan Kirsh added a comment - 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.
        Hide
        Craig L Russell added a comment -

        > 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.

        Show
        Craig L Russell added a comment - > 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.
        Hide
        Craig L Russell added a comment -

        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.

        Show
        Craig L Russell added a comment - 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.

          People

          • Assignee:
            Craig L Russell
            Reporter:
            Michelle Caisse
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development