Issue Details (XML | Word | Printable)

Key: JAVAEETUTORIAL-107
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Kim Haase
Reporter: Brant Gurganus
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
javaeetutorial

serializable class does not define serialVersionUID

Created: 24/Jun/12 11:52 PM   Updated: 05/Feb/13 09:21 PM   Resolved: 05/Feb/13 09:21 PM
Component/s: doc, examples
Affects Version/s: 6.0.7-5
Fix Version/s: 6.0.7-6, 6.0.8

Time Tracking:
Not Specified

Tags:
Participants: Brant Gurganus, Ian Evans, jendrock and Kim Haase


 Description  « Hide

The managed bean described at http://docs.oracle.com/javaee/6/tutorial/doc/gipob.html is marked as Serializable but does not define a serialVersionUID. While not technically necessary, I believe it is best practice to define it since different JVMs will generate different default serialVersionUIDs so retroactively setting a compatible serialVersionUID may not be easy.



Ian Evans added a comment - 14/Aug/12 07:00 PM

There also is the issue that NetBeans adds serialVersionUID as an editor hint, but defaults the value to 1L for every class. So, we need to sweep through our sources to make sure that we have unique IDs for our serializable classes.


Kim Haase added a comment - 14/Aug/12 09:05 PM

Yes.

A few other chapters in the book contain code with the 1L assignment. I am fixing the CDI one. It occurs in a couple of persistence chapters also.


Kim Haase added a comment - 15/Aug/12 03:33 PM

Checked in code and book fixes for web/guessnumber and cdi/guessnumber examples.


Ian Evans added a comment - 15/Aug/12 04:47 PM

Revision: 984
Author: ievans
Date: 2012-08-15 09:47
Message: Replaced all serialVersionUID fields with unique values; general code cleanup (added @Override annotation, StringBuilder, improved logging syntax, etc.)
Issue #JAVAEETUTORIAL-107 - serializable class does not define serialVersionUID


Kim Haase added a comment - 16/Aug/12 04:19 PM

Checked in code fixes for mailconnector example (revisions 988 and 989).


Kim Haase added a comment - 17/Aug/12 09:27 PM

Committed more bookstore example classes that needed a serialVersionUID, at revision 992.


Kim Haase added a comment - 20/Sep/12 01:40 PM

Committed cleaned-up code in cdi/decorators, including serialVersionUID, at revision 996.


Kim Haase added a comment - 20/Sep/12 02:01 PM

Committed cleaned-up code in cdi/billpayment, including serialVersionUID, at revision 997.


Kim Haase added a comment - 20/Sep/12 02:16 PM - edited

Committed cleaned-up code in cdi/producerfields, including serialVersionUID, at revisions 998 and 1001.


Kim Haase added a comment - 20/Sep/12 03:05 PM

Committed cleaned-up code in jms/clientmdbentity, including serialVersionUID, at revision 1000.


Kim Haase added a comment - 20/Sep/12 09:17 PM

Committed cleaned-up code in Duke's Forest projects, including serialVersionUID, at revision 1002.


jendrock added a comment - 05/Feb/13 09:21 PM

This issue has been fixed. Depending to whom you talk, this issue is either trivial or irrelevant. The 1L value, generated and inserted by the IDE is sufficient for the examples. In a real world production environment, a unique, generated UID would be a necessity, but not here. The change has been made to all or almost all of the examples already. Enough has been done to close the issue.