org.hibernate.AnnotationException: No identifier specified for entity
生活随笔
收集整理的這篇文章主要介紹了
org.hibernate.AnnotationException: No identifier specified for entity
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Caused?by:?org.hibernate.AnnotationException:?No?identifier?specified?for?entity:
?
使用hibernate的e-r映射pojo類的時候遇到org.hibernate.AnnotationException:?No?identifier?specified?for?entity異常。可是entity類的注釋沒有問題,唯一的不正常的地方是這張表比較特殊沒有主鍵,好像在使用hibernate的映射表的時候entity類是必須要主鍵的,否則就會報出這個異常。
解決辦法自然是add一個主鍵進去,這里主要是對實體類的注釋,應該做添加
?@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name?=?"id",?nullable?=?false)
privateint?id;
轉載于:https://blog.51cto.com/wangyaojie/1566021
總結
以上是生活随笔為你收集整理的org.hibernate.AnnotationException: No identifier specified for entity的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: VC++软件工程师高端培训
- 下一篇: centos安装g++