users@glassfish.java.net

RE: How does the TopLink (present on GF) persist _at_Serializable Objects?

From: Martin Gainty <mgainty_at_hotmail.com>
Date: Mon, 4 May 2009 16:26:34 -0400

i would first look into implementing a TopLinkSession
http://otndnld.oracle.co.jp/document/products/as10g/101320/doc_cd/web.1013/b28219/oracle/toplink/sessions/Session.html

then finally execute the nonSelectingCall:
http://otndnld.oracle.co.jp/document/products/as10g/101320/doc_cd/web.1013/b28219/oracle/toplink/sessions/Session.html#executeNonSelectingSQL_java_lang_String_

HTH
Martin
______________________________________________
Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité
This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.






> Date: Mon, 4 May 2009 15:36:46 -0300
> From: casmeiron_at_gmail.com
> To: users_at_glassfish.dev.java.net
> Subject: Re: How does the TopLink (present on GF) persist @Serializable Objects?
>
> Sorry, ignore the first lines about abstract class, I was talking about
> other entity.
>
> And also I forgot to set the values to the entity:
> List<String> values = new ArrayList<String>();
> values.add("a");
> values.add("b");
> MyEntityExample example = new MyEntityExample ();
> example.setId(new Long(1));
> example.setObject(values);
> manager.persist(example);
>
>
>
> On 5/4/09 2:46 PM, "Paulo Cesar Silva Reis" <casmeiron_at_gmail.com> wrote:
>
> > Sure, follow:
> >
> > // Abstract class that is used by 2 child classes. The field that I am
> > talking about is Object object.
> >
> > // Note that it works perfectly when persisted with EntityManager but when I
> > try to insert this object writing the bytes directly in the column (using
> > insert statement) toplink is not able to reconstruct the object later.
> >
> > My entity class is simple like this:
> >
> > @Entity
> > public class MyEntityExample implements Serializable {
> > private Long id;
> >
> > private Serializable object;
> >
> > @Id
> > public Long getId( ) {
> >
> > }
> >
> > public void setId( Long id ) {
> > this.setId(id);
> > }
> >
> > public Serializable getObject( ) { return this.object; }
> > public void setObject(Serializable object) { this.object = object; }
> >
> > So if I do that;
> >
> > List<String> values = new ArrayList<String>();
> > values.add("a");
> > values.add("b");
> > MyEntityExample example = new MyEntityExample ();
> > example.setId(new Long(1));
> > manager.persist(example);
> >
> > Everything work, I can easily get the object using:
> >
> > List<String> values2 =
> > (List<String>) manager.find(MyEntityExample.class, new
> > Long(1)).getObject();
> > values.equals(values2); // true
> >
> > But whether a try this approach:
> > CallableStatement cs = connection.prepareCall("INSERT INTO MyEntityExamle
> > (ID, OBJECT) VALUES(?, ?)");
> > cs.sestLong(1, new Long(1));
> > List<String> values = new ArrayList<String>();
> > values.add("a");
> > values.add("b");
> >
> > ByteArrayOutputStream out = new ByteArrayOutputStream();
> >
> > ObjectOutputStream objOut = new ObjectOutputStream(out);
> >
> > objOut.writeObject( values );
> > InputStream stream = new ByteArrayInputStream(out.toByteArray());
> >
> > cs.setBinaryStream(11, stream, out.toByteArray().length);
> >
> >
> > int res = cs.executeUpdate();
> > cs.close();
> >
> > And later whether I try to load the above object using EntityManager using:
> >
> > List<String> values2 =
> > (List<String>) manager.find(MyEntityExample.class, new
> > Long(1)).getObject();
> >
> > I get de described error.
> >
> > So which way do I need to write the serializable object so TopLink can
> > reconstruct it?
> >
> > Thanks.
> >
> >
> >
> > On 5/4/09 11:58 AM, "glassfish_at_javadesktop.org" <glassfish_at_javadesktop.org>
> > wrote:
> >
> >> Can you post your entity class?
> >> [Message sent by forum member 'e3133d3' (e3133d3)]
> >>
> >> http://forums.java.net/jive/thread.jspa?messageID=344852
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> >> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
> >>
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>

_________________________________________________________________
Hotmail® has ever-growing storage! Don’t worry about storage limits.
http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage1_052009