db-jdo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: jdo 1.0 + jdo 2.0
Date Mon, 27 Feb 2006 06:18:08 GMT
Hi Luc,

On Feb 26, 2006, at 10:21 AM, Luc Claes wrote:

> Hi Craig,
>
> Here follows a sample of what could be a problematic situation. But  
> maybe I'm missing something obvious.
> We are trying to mix a JDO 1.0 implementation (FastObjects) with a  
> JDO 2.0 implementation (JPOX 1.1). The problem occurs at runtime on  
> one of the 'makePersistent' call, depending on the included jdo jar  
> (1.x or 2.0).

Yes, we did not make JDO 1 and JDO 2 able to be used by the same  
application without using different class loaders for the jars. That  
is, you would have to load the persistence-aware code (the code that  
references any JDO API) into two different class loaders.

You might also run into issues using classes enhanced for JDO 1 with  
JDO 2.

Craig

>
> Luc
>
> import java.util.Properties;
>
> import javax.jdo.JDOHelper;
> import javax.jdo.PersistenceManager;
> import javax.jdo.PersistenceManagerFactory;
>
> public class Test {
> private void init() {
> // Create the JPOX 1.1 PMF
> Properties propertiesJPOX = new Properties();
> propertiesJPOX.setProperty 
> ("javax.jdo.PersistenceManagerFactoryClass","org.jpox.PersistenceManag 
> erFactoryImpl");
> // Other properties...
> PersistenceManagerFactory pmfJPOX =  
> JDOHelper.getPersistenceManagerFactory(propertiesJPOX);
>
> // Create the FastObjects PMF
> Properties propertiesFastObjects = new Properties();
> 	 propertiesFastObjects.setProperty 
> ("javax.jdo.PersistenceManagerFactoryClass","com.poet.jdo.PersistenceM 
> anagerFactories");
> // Other properties...
> PersistenceManagerFactory pmfFastObjects =  
> JDOHelper.getPersistenceManagerFactory(propertiesFastObjects);
>
> PersistenceManager pmJPOX = pmfJPOX.getPersistenceManager();
> PersistenceManager pmFastObjects =  
> pmfFastObjects.getPersistenceManager();
> 		
> Object objectToMakePersistent = null;
> // Here, various operations are taking place...
> 	
> // This will fail at runtime if we import the 1.x jdo.jar
> // because makePersistent is declared as returning void
> pmJPOX.makePersistent(objectToMakePersistent);
> 		
> // This will fail at runtime if we import the 2.0 jdo.jar
> // because makePersistent is declared as returning Object
> pmFastObjects.makePersistent(objectToMakePersistent);
> }
> }
>
>
> Craig L Russell wrote:
>> Hi Luc Claes,
>> JDO was designed to allow clean separation of application classes,  
>> so that you could mix and match implementations.
>> But maybe a more specific example of what you are trying to  
>> accomplish would help decide the issue.
>> Regards,
>> Craig
>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Mime
View raw message