自己理解, 不完全正确, 大致如下:
例: 某实体类 Person(int id,string name,int age); id 为主键.
新建: new Person(), 并且未给 id 赋值;
游离: new Person(), 并且给 id 赋值; 或者数据库获取的 Person 类实例, 然后关闭了 session;
持久化: 从数据库获取的 Person 类实例;
删除: 删除持久化的对象;
上面游离状态的对象 进行 persist 会报 detach xxx 错误 (也有可能是 flush 后或者事务提交后才报错 )
来源: http://www.bubuko.com/infodetail-2893451.html