Exactly! OJB even has a FieldConversion to be used for this purpose! You could of course also implemnt any other FieldConversion that avoids the roundtrip problems.
cheers, Thomas Brian Nahas wrote: > what about Base64 encoding the byte[] in the POST/GET traversal so the > encoding doesn't get tainted? > > sun.misc.BASE64Encoder is included in the standard JDK. > > Just a thought... > -Brian > > ----- Original Message ----- > From: "Russell Smyth" <[EMAIL PROTECTED]> > To: "'OJB Users List'" <[EMAIL PROTECTED]> > Sent: Thursday, October 03, 2002 11:19 AM > Subject: RE: How to obtain a unique OID for object recapture > > > >>But this method requires adding the GUID element to the object and >>the database. This is not usable in our environment, as we are working >>with essentially a "legacy" database. >> >>What I am looking for is a is a way to get a string from an existing >>object that can be used to recapture it. Something that basically >>encodes the class and its PK values. Identity->String->Identity would >>work well - unfortunately the Identity.toString() does not create >>something that can be used to reconstruct an Identity, and Identities >>cannot be created by strings anyway. >> >>I did try Identity.serialize()->String->byte[]->Identity. This can be > > done, > >>but will not work in my environment as the String must be passed through >>a web page and/or http POST/GET, and tye byte[]->String->byte[] trick >>uses an encoding that would be damaged in the web-page traversal. >> >>I was using Torque and made some modifications to it's ComboKey class >>that allowed such a Key->String->Key series, then just tacked on my >>class type. It seems that Identities get me 90% of the way there! >> >>I am open to any other ideas... >> >>Russell >> >> >>>-----Original Message----- >>>From: Thomas Mahler [mailto:[EMAIL PROTECTED]] >>>Sent: Thursday, October 03, 2002 3:05 AM >>>To: OJB Users List >>>Subject: Re: How to obtain a unique OID for object recapture >>> >>> >>>Have a look at the OJB org.apache.ojb.broker.util.GUID class. >>> >>>There is a little testcase that shows how to use store these GUIDs as >>>strings into the DB and reconstruct a GUID on loading from the DB. >>> >>>This is the entity class >>>src/test/org/apache/ojb/broker/GuidTestEntity.java >>>it uses a special FieldConversion to convert from GUID to >>>STring (see in >>>the repository_junit.xml) >>> >>>cheers, >>>Thomas >>> >>>Russell Smyth wrote: >>> >>>>We have a need for the ability to extract from an object a >>> >>>unique ID (OID) >>> >>>>that can be >>>>stored as a string, then used to recapture the original >>> >>>object. Essentially >>> >>>>we need a >>>>String GUID for each object. >>>> >>>>Currently we are working with the PersistenceBroker.I had >>> >>>originally thought >>> >>>>we could >>>>use the Identity class, but there appears to be no way to >>> >>>reconstitute an >>> >>>>Identity >>>>from it's stringified (toString) representation. >>>> >>>>Does anyone have any suggestions on a way to get where I am >>> >>>trying to get? >>> >>>>Thanks all >>>>Russell >>>> >>>>-- >>>>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]> >>> >>-- >>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]> > > > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
