-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Object Serialization in hibernate
PostPosted: Thu Dec 15, 2005 2:16 am 
Newbie

Joined: Fri Apr 01, 2005 2:15 am
Posts: 14
Hi all,

I am having some problem in understanding serialization.When we serialize an object we first implement Serializable interface and then write the object into a stream(file).
But when we make an object Serializable in hibernate we do not write it manually in stream.We just implement Serializable interface and nothing else.I want to know ,does hibernate writes this object into stream internally or anything else.Please let me know.

with regards,
ajse


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 15, 2005 4:20 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
I dont if I understand you right.
Are you talking about output to the database ?
This is done by hibernate using PreparedStatements,
each java attribute is set to a preparedStatement
when writing. When reading jdbc result sets are
used.

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 15, 2005 6:33 am 
Newbie

Joined: Fri Apr 01, 2005 2:15 am
Posts: 14
I want to know why we make our classes(corresponding to a table) serializable in hibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 15, 2005 8:49 am 
Newbie

Joined: Thu Dec 15, 2005 8:31 am
Posts: 10
They do not have to be Serializable for use with Hibernate. But if you want to return these objects to a remote client they will have to be.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 16, 2005 1:40 am 
Newbie

Joined: Fri Apr 01, 2005 2:15 am
Posts: 14
How this thing works?Hibernate write these objects into streams or jvm does this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 16, 2005 3:50 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
The JVM or you application server is doing this for you usually.
You can easily call it yourself using:

To stream:
Code:
ByteArrayOutputStream o = new ByteArrayOutputStream();
ObjectOutput output =
   new ObjectOutputStream(new BufferedOutputStream(os));
output.writeObject(obj);
output.close();


from stream:
Code:
InputStream is = new ByteArrayInputStream(os.toByteArray());
ObjectInputStream input =
   new ObjectInputStream(new BufferedInputStream(is));
Object copy= input.readObject();

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 16, 2005 3:55 am 
Newbie

Joined: Fri Apr 01, 2005 2:15 am
Posts: 14
Thanks for the reply


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.