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.
分享到:
相关推荐
1. **降低耦合度**:Hibernate通过对JDBC进行封装,使得应用程序可以更专注于业务逻辑的实现,而不必关心底层数据库的具体实现细节。 2. **简化开发流程**:Hibernate提供了一系列高级特性,如缓存机制、查询语言...
文件已上传到百度网盘,附件中是下载地址。... 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 ...
最后,推荐的Hibernate相关书籍可以帮助深入理解和掌握框架,例如《Hibernate in Action》和《Hibernate Tips: More than 70 solutions to common Hibernate problems》等,这些书籍通常会详细讲解Hibernate的基础...
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 ...
19. **JPA与Hibernate**:Java持久层API(JPA)和Hibernate是ORM(对象关系映射)工具,简化了数据库操作。 20. **Java性能调优**:包括JConsole、VisualVM等工具的使用,以及对内存、CPU、GC的监控和优化。 以上...
1. **基础语法**:包括变量声明、数据类型、运算符、流程控制(如if语句、for循环和while循环)以及异常处理。 2. **类与对象**:深入理解面向对象编程,如封装、继承和多态,以及如何设计和实现类。 3. **接口与...
Struts 2 Tips Struts 2 是一个流行的开源 MVC(模型-视图-控制器)框架,用于构建Java Web应用程序。这个框架极大地简化了企业级Web应用的开发,提供了丰富的特性,如动作映射、结果类型、拦截器、插件等。在本文...
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 ...
Spring-Hibernate-示例使用 Spring、Hibernate、Gradle、Eclipse、Tomcat、Mysql 的 Java Web 应用程序框架。 ##tips 如果您正在构建一个 web 应用程序,请确保您应用 'eclipse-wtp' 插件而不是 'eclipse'。
1. **安装与配置** - 下载Open Liberty最新版本的zip文件,解压到指定目录。 - 配置`server.xml`文件,这是Open Liberty的核心配置文件,用于定义服务器的行为和特性。 2. **启动与停止服务器** - 使用命令行...
1 20个Java基础Tips 2 abstract,static,final修饰符 3 ChinaUnix.net Java精华贴 4 ANT学习笔记 5 极度性能调整 <br> FAQs 1 关于ConnectionManager中的代码 2 关于...
This chapter focuses on using XDoclet for data persistence, including ORM frameworks like Hibernate. Key topics include: - **Data Persistence Overview**: An introduction to data persistence in Java ...