Hi,

Thomas Mahler wrote:
Hi again,

Christophe.Demarey wrote:

Hi all,

if the String argument is the result of As I said in my last mail, the PersistenceManager.newObjectIdInstance(Class pcClass, String str) failed executing toString on an object id instance.
With OJB,
newObjectIdInstance(Class pcClass, Identity.toString()) does not work!
We got a "java.io.IOException: Not in GZIP format".
We must use newObjectIdInstance(Class pcClass, Identity.serialize()).


But this method does not appear in the JDO specification :=(.


But o.a.ojb.broker.Identity itself does also not appear in the JDO spec!
Handling of Identity objects is left to the JDO implementor.

Ok. I agree with it!



My argument here is that the JDO spec does not contain an Identity object. It does also not contain any formal contract between Identity objects and the PersistencecManager.


So using Identity.serialize() is not against the JDO.


Here I'm not agree with you.
In the specification the JDO Helper allows you to get the Identity object of a persistent object via the getObjectId(java.lang.Object pc) method. This method returns a java.lang.Object (to let JDO vendors define their own Object Identity, for OJB : o.a.ojb.broker.Identity).


The newObjectIdInstance(java.lang.Class pcClass, java.lang.String str) of the PersistenceManager Class allows to create again an Identity Object from a String str.
This string can comes from getObjectId(java.lang.Object pc).toString().
JDO spec : "The String argument might have been the result of executing toString on an object id instance."


The method toString is define for all java Objects, so, in this case, the code is portable. There is no need to cast to a JDO Vendor specific type.
I tryed other JDO implementations and the awaited behaviour is that which I describe above.



So, if one want to use ObjectId with JDO, its software application is dependant on OJB and can't be used with another OJB implementation.


It becomes dependend by using OJB Identity objects already! Different JDO implementations will use diffent Identity concepts!

Yes, but there is no need to cast in a specific type because the method toString() works fine with Identity!



I think it could be usefull to rename the Identity.toString() method and
to implement a new Identity.toString() method :

public String toString()
{
    return new String( serialize() );
}

In this case, OJB will become JDO compliant with ObjectId.
I don't know if the actual Identity.toString() method is often used but I think rename this method will not change a big part of OJB. Am I wrong?


Identity.toString() is used to produce a human readable representation of an Identity. It is used in this way in several places.
So IMO it's not an option to change the semantics of toString().


The "real" solution could be to provide a Parser that can build Indentities from the Identity.toSTring() representation.
But that's a lot of work and the benefit is rather small, as using serialize() is not a violation of the JDO spec IMO.

I think this work is very important. Benefits are portability!! I think it's an important part of OpenSource projects.

Regards.


-- Christophe Demarey, Research engineer OpenCCM project - http://www.objectweb.org/openccm GOAL Team - CNRS/USTL/LIFL - http://www.lifl.fr/GOAL/ Universite des Sciences et Technologies de Lille LIFL - UMR CNRS 8022- Batiment M3 59655 Villeneuve d'Ascq Cedex - FRANCE Phone: +33 (0)32043 4728 Fax : +33 (0)32043 6566


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



Reply via email to