When implementing Serializable interface, in Java, we need to set it’s serialVersionUID long.
Is there any differences whether default or auto generated long should be chosen?
When should one be preferred over another?
If auto generated long is chosen, should it be changed in event class if changed? In other words the value that gets assigned to serialVersionUID .. is it related to current structure of the class and fields and methods that are declared there?
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 6749067740891125834L;
The serial version UID can be any number, its value has no specific meaning.
It makes sense and is convenient to start it with 1 and increment it every time the format changes.
You can only do that, however, if you thought about it from the beginning. If you already have existing data that you need to continue to be able to read, this data will have the auto-generated id. In this case, you have no choice, but to match that value.