保存hibernate实体时,
id将为您填充该属性。所以如果你有
MyThing thing = new MyThing();...// save the transient instance.dao.save(thing);// after the session flushes, thing.getId() should return the id.
实际上,我几乎总是
assertNotNull在测试中对持久实体的ID进行一次操作,以确保保存有效。

保存hibernate实体时,
id将为您填充该属性。所以如果你有
MyThing thing = new MyThing();...// save the transient instance.dao.save(thing);// after the session flushes, thing.getId() should return the id.
实际上,我几乎总是
assertNotNull在测试中对持久实体的ID进行一次操作,以确保保存有效。