8_实现Serializable接口_重写equals和hashCode方法

控制台java application运行报错:

19:20:51,916  WARN RootClass:233 - composite-id class does not override equals(): com.mym.hibernate.model.StudentPK
(意思是:composite-id没有重写equals()方法,在com.num.hibernate.model.StudentPK)
Exception in thread "main" org.hibernate.MappingException: composite-id class must implement Serializable: com.mym.hibernate.model.StudentPK
(意思是:composite-id 必须实现Serializable接口,在com.mym.hibernate.model.StudentPK类中)
     at org.hibernate.mapping.RootClass.checkCompositeIdentifier(RootClass.java:243)
     at org.hibernate.mapping.RootClass.validate(RootClass.java:224)
     at org.hibernate.cfg.Configuration.validate(Configuration.java:1149)
     at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1334)
     at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
19:20:51,918  WARN RootClass:238 - composite-id class does not override hashCode(): com.mym.hibernate.model.StudentPK
(意思是:composite-id没有重写hashCode()方法,在com.num.hibernate.model.StudentPK)
     at com.mym.hibernate.model.StudentTest.beforeClass(StudentTest.java:16)
     at com.mym.hibernate.model.StudentTest.main(StudentTest.java:41)


控制台报错:

17:56:09,344  WARN RootClass:233 - composite-id class does not override equals(): com.mym.hibernate.model.StudentPK
17:56:09,346  WARN RootClass:238 - composite-id class does not override hashCode(): com.mym.hibernate.model.StudentPK

Junit报错:
org.hibernate.MappingException: composite-id class must implement Serializable: com.mym.hibernate.model.StudentPK
(意思是:composite-id 必须实现Serializable接口,在com.mym.hibernate.model.StudentPK类中&#x
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值