-->
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.  [ 8 posts ] 
Author Message
 Post subject: serialVersionUID in persistant class?
PostPosted: Mon Jan 10, 2005 4:06 am 
Regular
Regular

Joined: Mon Aug 02, 2004 9:33 am
Posts: 69
Hibernate version: 2.1.6

Name and version of the database you are using:MySql 4.1.8

Do we really need to set serialVersionUID like below:

private static final long serialVersionUID = 3258409538872161584L;

in the persistant class with Serializable implementation?

regards,
prettyhandling


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 4:19 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No idea what you want, but no.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 6:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
It's not a Hibernate requirement at least.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 2:40 am 
Regular
Regular

Joined: Mon Aug 02, 2004 9:33 am
Posts: 69
Check this out:
http://www.javaworld.com/javaworld/java ... thser.html

http://java.sun.com/j2se/1.4.2/docs/gui ... tml#wp4100


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 20, 2005 12:28 pm 
Regular
Regular

Joined: Mon Aug 02, 2004 9:33 am
Posts: 69
so is it required/better to put serialVersionUID ?

prettyhandling wrote:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 20, 2005 12:31 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No, I don't really care what it is since I've no problems without it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 20, 2005 1:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
serialVersionUID is for managing different versions of a serialized class.

So, it is only relevant when you *serialize* classes (which hibernate only does when you actually save the complete object in e.g. a binary).

Then it only comes relevant if you want to ensure compability between previously saved instances and newer instances with possibly new fields.

So, the answer is: If you use serialization (note: serialization != persistens) with on objects which serialized structure might change in the future - then yes, serialversionui is worth setting....but please read the serialization docs for which this is relevant (with or without hibernate)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 20, 2005 6:14 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Bloch's effective java item 55

regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.