Hibernate tips 1

本文详细介绍了Hibernate框架中的关键概念,如配置文件设置、会话管理、对象状态转换等,并深入探讨了如何通过Hibernate进行数据持久化操作,包括保存、更新、删除等核心功能。

hibernate configure

inverse = true : parent side update wont have any result, on the reverse side, the changes will happen in database.


Session Lock

reattach the detached object


Session merge

1. dont associated the instance with session

2. If new object, will save a copy and return persisted object

3. If detached, will copy over to attached object (if no attached object, need load from database)

 

If persist object associated with trancient object, persist attached object will cascade to the transcient object as well if the cascade="all"....

 

OID can not be changed, better private setID()


Hibernate update

1. throw exception when wanna updating a detached object, while session already has object with same ID

2. can not update object which wasn't in database.


Condition of transcient object

1. OID is null

2. version is null

3. configure file:  id has unsaved-value, OID = unsaved-value

4. configure file: version value = unsaved-value for version

5. hibernate inteceptor , isUnsaved() return TRUE


Session delete

1. if attached - just delete it

2. if not attached - merge it first, then delete it


Session update & database trigger

to overcome this problem

1. after flush, refresh the updated object

2. useless update will trigger unnecessary database trigger, need set "Select-before-update" to compare object to know whether we need update the object.


 HQL

1. hql will match case insensitive data e.g. name = 'Tom'/'tom'/TOM', will match all of them.

文件已上传到百度网盘,附件中是下载地址。真正免积分免费完整版,绝不出现仅下载到部分章节,书中广 告页要求QQ联系支付宝购买完整版的流氓行为! 欢迎免积分下载更多本人独有网上难寻觅的 高清IT电子书:http://download.csdn.net/user/sinophp123 人无我有,人有我优,人优我廉!我的版本是全网最清晰的独家制作版本,还不要资源分。 同样一本书,下我的就可以了! 本人上传资料的原则: (1)如果CSDN和网上其他地方已随处可见高清下载,本人不再上传。 (2)如果网上已有我还上传,那么肯定是经重新制作,如不再缺页,清晰度更高,或者加上书签。 (3)每本书都经过逐页纯手工精心处理,包括清晰度的增强,水印的去除。当然最重要的,是尽量保证有书 签方便您浏览。 (4)如果是中译版,文件名前半部分是英文原版书名,后面是中译版书名。 如:“Implementing.Responsive.Design-响应式Web设计实践”。书名经反复校对绝无一字错漏。 (5)每本pdf书默认都是有书签的。来源不限“某星”网站,还有各大网络书店和出版社官网的页码信息。 凡无书签的pdf文件名均含“_no.bookmark”字样,如“HTML5程序开发范例宝典_no.bookmark”。请不要再 浪费时间去寻找书签,肯定没有,网上别人提供的下载版本也绝对不会有(除非您是出版社内部人员!), 没有人会浪费自己时间逐页输入章节页码来费时费力免费给您制作。 (6)只提供中文书籍,您不用担心下载的是英文原版。 (7)只提供完整版,绝不上传只有部分章节的所谓“迷你书”,“试读版”。 (8)书中绝不含广告页和水印LOGO。 Hibernate-A.Developer's.Notebook—Hibernate程序高手秘笈 [美] james elliott(著) | o'reilly taiwan公司编译(译) | 东南大学出版社 | 9787564106379 |
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值