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.
分享到:
相关推荐
文件已上传到百度网盘,附件中是下载地址。... Hibernate-A.Developer's.Notebook—Hibernate程序高手秘笈 [美] james elliott(著) | o'reilly taiwan公司编译(译) | 东南大学出版社 | 9787564106379 |
相当不多的解决方案,你可以按照书中规范完成相应的框架,理解其中的本质。
提示和技巧(Tips & Tricks) 12. 条件查询(Criteria Query) 12.1. 创建一个Criteria实例 12.2. 缩小结果集范围 12.3. 对结果排序 12.4. 关联(Associations) 12.5. 动态关联对象获取(Dynamic ...
1. Introduction to Hibernate 1.1. Preface 1.2. Part 1 - The first Hibernate Application 1.2.1. The first class 1.2.2. The mapping file 1.2.3. Hibernate configuration 1.2.4. Building with Ant 1.2.5. ...
提示和技巧(Tips & Tricks) 12. 条件查询(Criteria Query) 12.1. 创建一个Criteria实例 12.2. 缩小结果集范围 12.3. 对结果排序 12.4. 关联(Associations) 12.5. 动态关联对象获取(Dynamic ...
In addition, this book contains well separated, subjective material (opinion sidebars), comic illustrations, tips and tricks, all of which provide real-world and practical perspectives on relevant ...
In addition, this book contains well separated, subjective material (opinion sidebars), comic illustrations, tips and tricks, all of which provide real-world and practical perspectives on relevant ...
1.1. Part 1 - The first Hibernate Application ................................................................ 1 1.1.1. Setup .............................................................................
Spring-Hibernate-示例使用 Spring、Hibernate、Gradle、Eclipse、Tomcat、Mysql 的 Java Web 应用程序框架。 ##tips 如果您正在构建一个 web 应用程序,请确保您应用 'eclipse-wtp' 插件而不是 'eclipse'。
The tone of the book is intended to be light rather than pedantic and hints and tips based on the author’s life experience are included. Table of Contents Chapter 1 Stuff You Need to Know Chapter 2 ...
1 20个Java基础Tips 2 abstract,static,final修饰符 3 ChinaUnix.net Java精华贴 4 ANT学习笔记 5 极度性能调整 <br> FAQs 1 关于ConnectionManager中的代码 2 关于...
■CHAPTER 17 Tips and Tricks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 ■CHAPTER 18 Example: MP3 Manager . . . . . . . . . . . . . . . . . . . . . ....