对象状态可以从分离状态变为瞬态状态吗 [英] Can an object state change from detached to transient

查看:38
本文介绍了对象状态可以从分离状态变为瞬态状态吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Hibenate中,一个对象可以有3种状态-

In Hibenate, for an object there can be 3 states -

短暂,持久,独立.

transient, persistent, detached.

但是对象状态可以从分离状态变为瞬态状态吗?

But can a object state change from detached to transient and how is that possible?

推荐答案

否,这是不可能的.

Transient 对象是数据库中没有引用的对象.另一方面, Persistent detached 在数据库中具有表示形式(被持久化).分离的对象将保留,但是对于此对象,休眠会话将关闭.您可以将该对象移回持久状态,但是无法将其从分离状态更改为瞬态状态.

Transient object are objects with no reference in database. Persistent and detached on the other hand have representation in database (are persisted). Detached object is persisted, but for this object hibernate session is closed. You may move this object back to persistence state, but there is no way to change from detached to transient.

这篇关于对象状态可以从分离状态变为瞬态状态吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆