当前位置:网站首页>Hibernate entity class curd, transaction operation summary
Hibernate entity class curd, transaction operation summary
2022-06-25 23:34:00 【_ Qilixiang】
Full of dry goods !
Catalog
Hibernate Transaction operation of
Add operation
save() Method


saveOrUpdate() Method

Inquire about

result :

modify

Use save() The method is completely consistent with this effect :

Direct... Is not recommended new Object readjustment update() Method , This results in a null value .
Delete operation
The first one is : according to ID Inquire about , Returns the object , call delete() Method to delete the object

The second kind :new object , call delete() Method to delete the object
Save or update
saveOrUpdate()
Instantaneous time : This method does the add operation

Persistent state : Modify the operating

In managed status : Modify the operating

Tool class encapsulation
package com.wl.utils;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/*
* Extract tool class
*/
public class HibernateUtils {
private static final Configuration cfg ;
private static final SessionFactory sessionFactory ;
static{
cfg = new Configuration();
cfg.configure();
sessionFactory = cfg.buildSessionFactory();
}
// This method returns this sessionFactory object
public static SessionFactory getSessionFactory(){
return sessionFactory;
}
}
Object state of entity class
Instantaneous state
No in object id value , Object and the session There's no connection .
Persistence state
Among objects id value , Object and the session relation
Trusteeship
Among objects id value , Object and the session There's no connection
Hibernate Transaction operation of
Rule writing of transaction code
try{
Open transaction
Commit transaction
}catch(){
Roll back the transaction
}finally{
Closing transaction
}
边栏推荐
- Efr32bg22 ble module (low power Bluetooth communication module) at command test
- CSDN force value
- 【AXI】解读AXI协议乱序机制
- RepOptimizer: 其实是RepVGG2
- Qt自定义实现的日历控件
- Recently prepared to translate foreign high-quality articles
- 【opencv450 samples】创建图像列表yaml
- 经典图像分割网络:Unet 支持libtorch部署推理【附代码】
- 软件测试面试一直挂,面试官总是说逻辑思维混乱,怎么办?
- qtcreator 格式化代码
猜你喜欢

指针强化与提高

CTS RTS RX TX in serial port flow control UART (direct communication between serial port module and MCU)

Multithreaded learning 2- call control

#23class介绍

(serial port Lora module) centrida rf-al42uh private protocol test at instruction test communication process

提取系统apk

C language (I)

音频基础知识以及PCM转WAV

Meta universe standard forum established

Idea shortcut
随机推荐
漏刻有时API接口实战开发系列(13):小鹅通云服务PHP-API二维数组传参解决方案
音频基础知识以及PCM转WAV
Episode 3: thread synchronization using thread lock
Qt 中文和英文分别使用不同的字体
Live800 online customer service system: do business across time and space, starting from each interaction
Kubernetes cluster construction of multiple ECS
Day4 branch and loop summary and operation
#23class介绍
Svn icon disappearing solution
konva系列教程2:绘制图形
go中全类型等值判断解析&综合汇总
ACM. HJ16 购物单 ●●
STM32 development board + smart cloud aiot+ home monitoring and control system
RepOptimizer: 其实是RepVGG2
二进制、16进制、大端小端
CTS RTS RX TX in serial port flow control UART (direct communication between serial port module and MCU)
#24class静态成员
记一次beego通过go get命令后找不到bee.exe的坑
LM small programmable controller software (based on CoDeSys) note XVII: PTO pulse function block
character string