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

346

被折叠的 条评论
为什么被折叠?



