|
| icesummit 回复于:2005-08-21 19:45:40
|
偶用的就是generated,但是仍然是1L。
|
| yovn 回复于:2005-08-23 21:47:34
|
[quote:002399fc2a="wolfg"]
抱歉,上面写错了,应该是“还有一个随机的”,见图。default就是1L,generated就是随机的[/quote:002399fc2a]
这个应该不是随机的,是根据Class Name,Filed,Method等等算的Hash值,具体的算法,可以看Java Serializable 规范。
选择Default,1L也是可以的,不是只根据这个字段来唯一标识一个Class的。
|
| wolfg 回复于:2005-08-23 22:41:26
|
[quote:4611655dec="yovn"]
这个应该不是随机的,是根据Class Name,Filed,Method等等算的Hash值,具体的算法,可以看Java Serializable 规范。
选择Default,1L也是可以的,不是只根据这个字段来唯一标识一个Class的。[/quote:4611655dec]多谢指教! :)
|
| cooljia 回复于:2005-08-24 00:44:14
|
A good way to solve many problem with object that are Serializable (EJB
implementation are) is to add the serialVerUID in every Serializable class. To add
it, compile your class, then run serialVer with your fully qualified class name as
an argument and it will print the line to add to your class.
Add that line to the class and recompile. Now when you modify the class, it will
have the same serialVerUID and it will cause less error at runtime. This is
notdangerous to do, because if a new version of a class in not compatible with an
old one, unserializing it will still cause an exception when tring to assign
incompatible fields.
1. serialVer.exe这个工具可以在jdk的目录下查找到.
2. 基本上加入类的这个成员变量将会看起来是这个样子的static final long serialVersionUID = -2199636203015991542L;
|
| cooljia 回复于:2005-08-24 00:45:20
|
有个问题, wolfg, 在我的eclipse3.0中, implements Serializable并不能带来你那个小灯泡, 是不是RPWT啊?
|
| sakulagi 回复于:2005-08-24 08:42:48
|
试试Eclipse 3.1没准就可以了。肯定不是RPWT,hoho
|
| dennis2 回复于:2005-08-28 15:03:45
|
> 在我的eclipse3.0中, implements Serializable并不能带来你那个小灯泡, 是不是RPWT啊?
(这个 ... 不好意思,什么是 RPWT 啊?)
serialVerUID 只是在 JDK 5 中才是强迫使用的,而 eclipse 只是在 3.1 才支持 5,所以在 3.0 里面没有错误提示。
|
| sakulagi 回复于:2005-08-28 17:32:02
|
RPWT == Ren Pin Wen Ti (人品问题,类似于“点背不能怨社会,命苦不能赖政府”的说法)
|
| goncha 回复于:2005-08-28 20:27:58
|
是否把未声明searialVersionID做为Error是可以在Java相关的属性里做设置的.
|
| goncha 回复于:2005-08-28 20:32:40
|
不知道自动生成的serialVersionID会不会根据类中持久化Field的增减自动做调整, 不然serialVersionID不过是个摆设.
|