【第一章 Design】 2 Cayenne 持久化对象生存期

本文介绍Apache Cayenne框架中持久化对象的状态及其转换过程。详细解释了TRANSIENT、NEW、COMMITTED、MODIFIED、HOLLOW和DELETED等状态,并说明了这些状态如何随数据上下文的变化而变化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

持久化对象的生存期可以描述为可以相互转化的几种状态,并且预定义了整数型的常量值,定义在org.apache.cayenne.PersistenceState 类中。在应用程序和持久化对象或者Cayenne上下文交互时,状态发生变化。无论什么时候状态发生了变化,Cayenne会调用setPersistenceState()方法,自动更新所有受到影响的对象的persistenceState的属性值。

 

 

新建对象的状态变化:

自动获取或者提交对象状态变化:

预定义的几种状态:

状态 描述
TRANSIENT1The object is not registered in a DataContext and will not persist.
NEW2The object is freshly registered in a DataContext, but has not been persisted to the database (there is no matching database record).
COMMITTED3The object is registered in a DataContext and has been persisted to the database (there is a matching database record).
MODIFIED4The object is registered in a DataContext and there is a matching database record and the object has been modified in memory, but the changes have not yet been persisted back to the database.
HOLLOW5The object is registered in a DataContext and has a corresponding database row, but the values have not yet been fetched from the database. The values will be fetched/faulted from the database automatically by Cayenne if any fields are requested from the object.
DELETED6The object is registered in a DataContext and will be deleted from the database upon commit.


 

原文:

http://cayenne.apache.org/doc30/persistent-object-lifecycle.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值