db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Samson" <eric.sam...@xcalia.com>
Subject RE: A JDO-JPA Bridge
Date Mon, 09 Oct 2006 10:21:23 GMT
Hi all,

 

We've already implemented something like that.

It won't be a big deal to make it compliant with the final names once we will have agreed
upon them.

 

Considering that EJBQL3 is de facto supported as JDO support optional query languages, we
just have to define compliant annotations and then JDO2 won't be far from being a superset
of EJB3/JPA.

 

Best Regards,

....: Eric Samson, Founder & CTO, xcalia

Service your Data!

________________________________

De : Ilan Kirsh [mailto:kirsh@objectdb.com] 
Envoyé : samedi 7 octobre 2006 20:09
À : jdo-dev@db.apache.org; JDO Expert Group
Objet : A JDO-JPA Bridge

 

Hi all,

Following is an enhancement suggestion for JDO 2.1 (or maybe even for JDO 2.01?) that may
give maximum results in minimum effort.

I suggest to add four new interfaces to javax.jdo (or to a sub package):

public interface JEntityManagerFactory extends
    javax.persistence.EntityManagerFactory, javax.jdo.PersistenceManagerFactory
{
}

public interface JEntityManager extends
    javax.persistence.EntityManager, javax.jdo.PersistenceManager
{
}

public interface JEntityTransaction extends
    javax.persistence.EntityTransaction, javax.jdo.Transaction
{
}

public interface JQuery extends
    javax.persistence.Query, javax.jdo.Query
{
}

JDO 2.1 Implementations that will support the new optional "javax.jdo.option.JPA" feature
will have to return instances of these interfaces instead of the super interfaces when using
either the JDO API or the JPA API.

 

For instance, a JDO 2.1 implementation with JPA 1.0 support will support datastore transactions
(currently only optimistic transactions are supported by JPA):

 

    EntityManagerFactory emf = Persistence.createEntityManagerFactory("myUnit");

    EntityManager em = emf.createEntityManager();

    ((JEntityTransaction)em.getTransaction()).setOptimistic(false);

 

And will support using Extent (no Extent in JPA and I think that there is no support for filtering
subclasses, at least not in an easy way):

 

    EntityManagerFactory emf = Persistence.createEntityManagerFactory("myUnit");

    EntityManager em = emf.createEntityManager();

    Extent extent = ((JEntityManager)em).getExtent(MyClass, false);

 

As well as many other things that are missing in JPA, for example:

 

    boolean isDirty = JDOHelper.isDirty(entity);

    EntityManager em = (EntityManager)JDOHelper.getPersistenceManager(entity);

 

These examples are for using JPA with JDO extensions which I think is more interesting. Of
course, similar examples can be written also for the other direction (using JPA from JDO).

 

The names of the new four interfaces is based on the JPA interface names in a way that may
suggest that they are more powerful. Which do you consider more powerful AWT Frame, Panel
and Button or Swing JFrame, JPanel and JButton? If JPA will catch then every curious Java
developer will soon know that there is EntityManager but there is also JEntityManager that
supports additional operations and unlike Hibernate or TopLink extensions is supported by
many vendors and backed by a standard! I agree with David that some day the majority of the
JPA implementations might be also JDO implementations. In that case, JEntityManagerFactory,
JEntityManager, JEntityTransaction, JQuery, JDOHelper and Extent may be something significant
that cannot be ignored in the JPA market.

 

The minimum that is required in order to support this addition in JDO 2.1 is:

- Adding the four new interfaces.

- Adding "javax.jdo.option.JPA" to the specification with a short explanation.

 

Actually the maximum is not so far from the minimum:

- New section in the specification that explains this addition with more details and maybe
some examples.

- Handling possible conflicts (e,g, which exceptions are thrown JDO or JPA?).

- TCK tests that check that an implementation that claims to support "javax.jdo.option.JPA"
indeed returns instances of the new four interfaces.

 

Of course, no need to describe the JPA in the JDO spec or write JPA tests because all this
is already handled by the EJB 3 spec.

 

Accepting this suggestion will enable using JDO in two modes:

1. Standalone (for current users as well as for new users that are interested).

2. As an extension to JPA (might be very useful if JPA will catch).

 

Any comments will be welcomed.

 

Regards,

 

Ilan Kirsh

ObjectDB Software

http://www.objectdb.com

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message