Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 61549 invoked from network); 23 Apr 2004 15:30:49 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 23 Apr 2004 15:30:49 -0000 Received: (qmail 44242 invoked by uid 500); 23 Apr 2004 15:30:43 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 44203 invoked by uid 500); 23 Apr 2004 15:30:42 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 59679 invoked from network); 23 Apr 2004 13:36:15 -0000 X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Disposition-Notification-To: Subject: RE: Criteria object serialization/deserialization Date: Fri, 23 Apr 2004 09:36:15 -0400 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Criteria object serialization/deserialization Thread-Index: AcQmKQPQCQjUk7+ZRRyzinhHwsikxwDDq/lQ X-Priority: 1 Priority: Urgent Importance: high From: To: X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Since I got no answer on this, I have coded a serializer/deserializer = for the Criteria class. And I must say that it wokrs quite fine. If anyone thinks that this could be a = good addition to the Torque code base, please let me know and I'll be happy to share = it. I don't claim it is perfect but=20 it does quite a good job so far. Thx! MG=20 --=20 Martin Goulet, B.Sc.=20 Senior Software Architect SunGard Front Office Solutions=20 Email: Martin.Goulet@sungard.com=20 Web: www.online.sungard.com=20 > -----Original Message----- > From: Goulet, Martin =20 > Sent: Monday, April 19, 2004 12:12 PM > To: 'torque-dev@db.apache.org' > Subject: Criteria object serialization/deserialization >=20 > Hello, >=20 > Anyone has ever tried to serialize a Criteria object into a byte = array? > I've implemented a Criteria serializer/deserializer and I get weird = results out of > it. For example, if I print the Criteria (through the toString() = method) before > and after it looks like the same criteria but the where clause is = malformed: >=20 > BEFORE: Criteria:: = CSLogin.LOGINNAME<=3D>CSLogin.LOGINNAME=3D'MONICA.BELLUCI': =20 > Current Query SQL (may not be complete or applicable): SELECT FROM = CSLogin WHERE CSLogin.LOGINNAME=3D'MONICA.BELLUCI' >=20 > AFTER : Criteria:: = CSLogin.LOGINNAME<=3D>CSLogin.LOGINNAME=3DCSLogin.LOGINNAME=3D'MONICA.BEL= LUCI': =20 > Current Query SQL (may not be complete or applicable): SELECT FROM = CSLogin WHERE CSLogin.LOGINNAME=3DCSLogin.LOGINNAME=3D'MONICA.BELLUCI' >=20 > Notice that the where clause has twice the "CSLogin.LOGINNAME"... = Obviously > when I try to put that through a doSelect, it doesn't work at all! So = has anyone > succeeded into serializing a Criteria into a byte array? Any feedback = would > be very much appreciated!! Thx!! >=20 > My code to serialize and deserialize is: >=20 > public void testSerialize() throws Exception > { > Criteria crit, crit2; > =09 > crit =3D new Criteria(); > crit.add( CSLoginPeer.LOGINNAME, "MONICA.BELLUCI" ); > crit2 =3D deserialize( serialize( crit ) ); > System.out.println( "BEFORE: " + crit.toString() ); > System.out.println( "" );=20 > System.out.println( "AFTER : " + crit2.toString() ); > } > =09 > /** > * Serializes the given object into a String. > * > * @param foo the object to serialize > * @returns the serialization of the given object > * @throws IOException when doublewords attack > **/ > public byte[] serialize(Criteria foo) throws IOException { >=20 >=20 > // The object is written to a ByteArrayOutputStream, so we can make = a String from the byte array. > ByteArrayOutputStream byteStream =3D new ByteArrayOutputStream(); > ObjectOutputStream objStream; > =09 > // Writes the object out to byteStream's internal byte array. > objStream =3D new ObjectOutputStream(byteStream); > objStream.writeObject(foo); // IOException > objStream.close(); >=20 > // Convert byteStream's byte array to a String. > =09 > return byteStream.toByteArray(); >=20 > } >=20 >=20 > /** > * Deserializes the given String into an Object. > * > * @param bar the String to deserialize > * @returns the object represented by the given serialization > * @throws IOException when doublewords attack > **/ > public Criteria deserialize( byte[] foo ) throws IOException, = OptionalDataException, ClassNotFoundException, StreamCorruptedException = { > =09 > ByteArrayInputStream byteStream; > ObjectInputStream objStream; > =09 > byteStream =3D new ByteArrayInputStream( foo ); > =09 > objStream =3D new ObjectInputStream( byteStream ); // IOException, = StreamCorruptedException > =09 > return (Criteria) objStream.readObject(); // OptionalDataException, = ClassNotFoundException > } >=20 >=20 >=20 > MG=20 > --=20 > Martin Goulet, B.Sc.=20 > Senior Software Architect > SunGard Front Office Solutions=20 > Email: Martin.Goulet@sungard.com=20 > Web: www.online.sungard.com=20 >=20 >=20 --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org