本站首页    管理页面    写新日志    退出


«October 2025»
1234
567891011
12131415161718
19202122232425
262728293031


公告
 本博客在此声明所有文章均为转摘,只做资料收集使用。

我的分类(专题)

日志更新

最新评论

留言板

链接

Blog信息
blog名称:
日志总数:1304
评论数量:2242
留言数量:5
访问次数:7644089
建立时间:2006年5月29日




[Hibernate]Session.evict(Object object), Session.setReadOnly(Object entity, boolean readOnly)
软件技术,  电脑与网络

lhwork 发表于 2006/6/15 11:22:29

public void evict(Object object) throws HibernateException    Remove this instance from the session cache.     Changes to the instance will not be synchronized with the database.     This operation cascades to associated instances if the association is mapped with cascade="evict".Test Casehbm.xml <class name="Customer" table="CUSTOMER" dynamic-insert="true" dynamic-update="true">    <id name="id">        <generator class="hilo"/>    </id>        <property name="code" not-null="true" length="50" />    <property name="name" not-null="true" length="200" />    <property name="status" length="20" /></class>Java code Session s = openSession();Transaction t = s.beginTransaction();Customer c = (Customer) s.get(Customer.class, new Long(1));s.evict(c);c.setName("IBM");t.commit();s.close();show sql Hibernate: select customer0_.id as id0_0_, customer0_.code as code0_0_, customer0_.name as name0_0_, customer0_.status as status0_0_ from CUSTOMER customer0_ where customer0_.id=?public void setReadOnly(Object entity, boolean readOnly)    Set an unmodified persistent object to read only mode, or a read only object to modifiable mode.     In read only mode, no snapshot is maintained and the instance is never dirty checked.Test CaseJava code Session s = openSession();Transaction t = s.beginTransaction();Customer c = (Customer) s.get(Customer.class, new Long(1)); s.setReadOnly(c, true);c.setName("IBM");t.commit();s.close();show sql Hibernate: select customer0_.id as id0_0_, customer0_.code as code0_0_, customer0_.name as name0_0_, customer0_.status as status0_0_ from CUSTOMER customer0_ where customer0_.id=?参考:1. Hibernate Reference Documentation2. Hibernate API Documentation3. Hibernate Test Source


阅读全文(2169) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.980 second(s), page refreshed 144792387 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号