如何在模型中設置ID?我試試這個代碼:如何用我的ID保存實體
public Community(Long id, ...) {
this.id = id;
....
}
但是,當我這樣做:
Communtiy c = new (1, ...);
c.save();
休眠說:
Execution exception PersistenceException occured : org.hibernate.PersistentObjectException: detached entity passed to persist: models.Community
請提供關於'Model'信息。你正在使用什麼樣的代碼類型? 這個問題看起來類似於你的http://stackoverflow.com/questions/2108178/id-generatedvalue-but-set-own-id-value。 – Thor 2012-03-03 07:40:01
@elmes只是累了) – 2012-03-03 10:34:25