自定义Usertype不能更新的问题(特殊情况)
问题解决,是deepCopy方法没写好。
数据库是mysql5.0。
由于用户表有很多跟用户相关的数据,但是平时查询不作为条件使用,所以我设置了一个text字段Properties用于记录用户的一些信息,比如电话号码身份证等等。
接着问题就是,insert操作的时候这个字段的值可以被插入,但是update操作的时候,这个值无论怎么设都无法更新,似乎是hibernate不知道这个值被更新了。
更新时的代码applicationUser.setGender(Gender.MALE); applicationUser.getProperties().setLastProductPoin(product.getPoin()); applicationUser.getProperties().setLastProductTitle(product.getTitle()); applicationUser.getProperties().setLastProductTagRootPoin( product.getTagRootPoin()); applicationUser.getProperties() .setLastProductTagRootTitle(tagRootTitle); applicationUser.getProperties().setLastProductDateTime( "2007-01-01 11:00:00"); applicationUserPersister.update(applicationUser);
其他类型可以,比如性别的,直接user.setGender(Gender.MALE),接着update就可以更新,可是上面那个就是不行,请大家帮我看看是为什么。谢谢
1 楼 suyejun 2007-11-16 好像知道了,可能是equals和hashcode方法没override。 2 楼 suyejun 2007-11-16 suyejun 写道好像知道了,可能是equals和hashcode方法没override。两个方法覆盖了还是不行