[
http://opensource.atlassian.com/projects/hibernate/browse/HBX-964?page=co...
]
jahlborn commented on HBX-964:
------------------------------
i'll throw out a reason for adding a serialVersionUID: because the classes are broken
without one. Point "B)" in the first comment is not really true. adding a
serialVersionUID does not indicate that a class is serializable across versions. that is
indicated by maintaining the *same* serialVersionUID across multiple versions of the
class. as to my original point, a Serializable class without a serialVersionUID is broken
because any serialized instance of that class are not guaranteed to be unserializable,
ever. serialVersionUID values are generated on the fly for classes without them, and a
jvm is free to generate one however it likes. so, today i generate a file with my
serialized objects. without touching my classes, i upgrade my jvm (needed a few bug
fixes, or, hey, maybe i even switch jvm vendors) and suddenly i can no longer read any
objects from that file.
you should be generating the full serialVersionUID, and that will not imply that the class
is serializable across versions because pretty much any change to the class will result in
a new serialVersionUID (so the behavior will be correct by default).
add serialVersionUID to entity classes
--------------------------------------
Key: HBX-964
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HBX-964
Project: Hibernate Tools
Issue Type: Improvement
Components: hbm2java
Affects Versions: 3.2beta10
Reporter: Dan Allen
Priority: Minor
Attachments: HBX-964-v1.txt
Original Estimate: 5 minutes
Remaining Estimate: 5 minutes
The serialVersionUID is recommended for classes that implement java.io.Serializable. The
hbm2java task should either set the serialVersionUID to 1L or automatically generate a
value. I prefer setting it to 1L because it is easy and it will work, but if you feel
motivated, you can look at what Eclipse does to generate this value from the class
signature.
I have included a patch that just sets it to 1L.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira