Code Garden
Grow code flowers and debug everyday.
code種子栽培筆記及debug經驗筆記。
2015年2月24日 星期二
[Bug] javax.persistence.EntityExistsException: a different object with the same identifier value was already associated with the session: [Model Name#index]
出現此Bug為在persistence中有已有一個Primary key相同的物件存在
若該Primary key為自動累加的流水號
需在JPA特別設定
@GeneratedValue(strategy=GenerationType.IDENTITY)
如下:
@Id
@GeneratedValue
(strategy=GenerationType.
IDENTITY
)
@Column
(name =
"id"
,length = 15)
private
Integer
id
;
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言