You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-user@db.apache.org by Luc Claes <lu...@contactoffice.com> on 2006/02/26 16:00:20 UTC

jdo 1.0 + jdo 2.0

Hi,

Is it / should it be possible to handle simultaneously JDO 1.0 and JDO 
2.0 providers in the same application ?
For instance, we would like to handle simultaneous accesses to Versant's 
FastObjects (JDO 1) and JPOX 1.1 or another JDO 2 O/R mapper. 
Unfortunately, it seems very unlikely that Versant will ever upgrade its 
FastObjects Java API.

Thanks.

Luc Claes


Re: jdo 1.0 + jdo 2.0

Posted by Craig L Russell <Cr...@Sun.COM>.
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!


Re: jdo 1.0 + jdo 2.0

Posted by Luc Claes <lu...@contactoffice.com>.
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).

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.PersistenceManagerFactoryImpl");
// Other properties...
PersistenceManagerFactory pmfJPOX = 
JDOHelper.getPersistenceManagerFactory(propertiesJPOX);

// Create the FastObjects PMF
Properties propertiesFastObjects = new Properties();
	 
propertiesFastObjects.setProperty("javax.jdo.PersistenceManagerFactoryClass","com.poet.jdo.PersistenceManagerFactories");
// 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


Re: jdo 1.0 + jdo 2.0

Posted by Craig L Russell <Cr...@Sun.COM>.
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

On Feb 26, 2006, at 7:00 AM, Luc Claes wrote:

> Hi,
>
> Is it / should it be possible to handle simultaneously JDO 1.0 and  
> JDO 2.0 providers in the same application ?
> For instance, we would like to handle simultaneous accesses to  
> Versant's FastObjects (JDO 1) and JPOX 1.1 or another JDO 2 O/R  
> mapper. Unfortunately, it seems very unlikely that Versant will  
> ever upgrade its FastObjects Java API.
>
> Thanks.
>
> Luc Claes
>

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!