Hi Mats,

Mats Strandberg wrote:
> There seems to be an incompatible change between 0.9.7 and 0.9.8 in
> the way persistence works using the JDO part of OJB.

Yes, that's right. We removed the JDO prototype and replaced it with the JDORI plugin solution.

>
> Using JDO in 0.9.8 seems to require "bytecode enhancement" while
> using JDO in 0.9.7 did not.

correct!
The 0.9.7 code was a prototype, it did not comply to the JDO spec in many ways. The new 0.9.8 solution is a plugin to the reference implementation, thus it require bytecode enhancement.
There is a target enhance-jdori in the build.xml file that shows how to invoke the enhancer. You can easiliy adopt this for your own classes.

> Background: -----------
>
> I am not an experienced user of OJB som some of the problems I
> describe below may just reflect my limited knowledge of OJB.
>
> I have been using the JDO API of OJB 0.9.7 (I've installed only the
> binary version of 0.9.7).
>
> I upgraded to 0.9.8 and found that the class:
> org.apache.ojb.jdo.PersistenceManagerFactoryImpl was gone.
>
> This is the class I used to get an implementation of
> javax.jdo.PersistenceManagerFactory so it is vital.
>
> I cannot find any PersistenceManagerFactoryImpl anywhere in the 0.9.8
> release so I guess this means that it is no longer supported.
>

The old protoytpe was never officially supported. It was a first draft, to show that a JDO compliant API can be build on top of OJB.
Thus we kicked out the stuff without any deprecation phase.

> The examples Tutorial 4 of the OJB 0.9.8 documentation now uses
> org.apache.ojb.jdori.sql.OjbStorePMF instead of
> PersistenceManagerFactoryImpl (as in the examples in OJB 0.9.7).
>
> The class OjbStorePMF does not seem to be part of any of the jar
> files of the binary distribution but the source files are included in
> the source distribution.
>

correct. I will patch the build script to include the new stuff in the binary distribution too!

> The Release Notes says: - JDO support by providing a plugin to the
> JDO reference implementation
>
> so I downloaded the reference implementation (jdori.jar) from Sun
>
> (Sun only provides a reference implementation for "Solaris/SPARC",
> but I guess I can be using this jar file on Windows as well?)
>

I've tested it under Windows and Linux without problems.

> When I execute my query (that worked in 0.9.7):
>
> Query query = manager.newQuery(Person.class);
>
> I get:
>
> javax.jdo.JDOUserException: Class given to getExtent does not
> implement javax.jdo.spi.PersistenceCapable
>
>> From what I remember the thing with JDO is that my classes need not
>> implement
> any interface to be persistence capable nor do I need to run them
> through any "class enhancer".
>

The JDO spec defines that all persistent classes can only be handled by a JDO implementation, if they implement PersistenceCapable.
The JDO spec mentions several ways to make classes implement this interface:
- bytecode enhancement (preferred way)
- preprocessing of sourcecode
It does not prescribe which solution is to be used. But it clearly states that a JDO implementation will have to use one of these approaches.

The JDO reference implementation uses bytecode enhancement! the enhancement process will make your Person class implement the PersistenceCapable interface (and many more things...). This is not an OJB fancy. This is just how the JDO spec wants a JDO implementation to work!

> I noticed a step 2 in the OJB 0.9.8 tutorial "... perform bytecode
> enhancement ..."
>
> while the "features list" still says:
>
> Transparent persistence: Persistent classes don't have to inherit
> from a persistent base class or to implement an interface.
>
> So, what am I missing?
>
> Is there no "Transparent persistence" when using OJB/JDO?

The JDO spec still claims to provide transparent persistence, as the developer does not see the PersistenceCapable stuff in the source code.
(The PersistenceCapable stuff is regarded as part of the compilation process.)
So IMO we don't have to change the statement in the feature list. This is definitely a JDO specific issue!

There have been many discussions if bytecode enhancement is a good concept or not. IMO aspect weaving is a much cleaner approach than bytecode manipulation. Maybe it is a good idea to use AspectJ for the OJB cleanroom JDO implemenation (which is in scope for OJB 2.0).

cheers,
Thomas



>
> Greatful if anyone could clarify.
>
> Best Regards / Mats
>
>
>
>
>
>
> -- To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]> For additional
> commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
>
>



--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to