博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JPA动态SQL
阅读量:3952 次
发布时间:2019-05-24

本文共 2581 字,大约阅读时间需要 8 分钟。

在类的头上打上 @DynamicInsert

@DynamicUpdate

即可自动动态更新

@Test    void updateOne() {
// apiInfoDemoRepository. apiInfoDemoRepository .save( new ApiInfoDemo().setId(5L) .setTitle("fuckkkk") .setMarkdownInfo("hwllorld world") .setTitle("xxooxx") ); // apiInfoDemoRepository.equals() System.out.println(apiInfoDemoRepository.findById(5L)); }

Hibernate: select apiinfodem0_.id as id1_0_0_, apiinfodem0_.gmt_create as gmt_crea2_0_0_, apiinfodem0_.gmt_modified as gmt_modi3_0_0_, apiinfodem0_.markdown_info as markdown4_0_0_, apiinfodem0_.method as method5_0_0_, apiinfodem0_.request_header as request_6_0_0_, apiinfodem0_.request_json as request_7_0_0_, apiinfodem0_.request_param as request_8_0_0_, apiinfodem0_.response as response9_0_0_, apiinfodem0_.response_header as respons10_0_0_, apiinfodem0_.tag as tag11_0_0_, apiinfodem0_.title as title12_0_0_, apiinfodem0_.url as url13_0_0_ from api_info_demo apiinfodem0_ where apiinfodem0_.id=?

Hibernate: update api_info_demo set gmt_modified=?, markdown_info=? where id=?
Hibernate: select apiinfodem0_.id as id1_0_0_, apiinfodem0_.gmt_create as gmt_crea2_0_0_, apiinfodem0_.gmt_modified as gmt_modi3_0_0_, apiinfodem0_.markdown_info as markdown4_0_0_, apiinfodem0_.method as method5_0_0_, apiinfodem0_.request_header as request_6_0_0_, apiinfodem0_.request_json as request_7_0_0_, apiinfodem0_.request_param as request_8_0_0_, apiinfodem0_.response as response9_0_0_, apiinfodem0_.response_header as respons10_0_0_, apiinfodem0_.tag as tag11_0_0_, apiinfodem0_.title as title12_0_0_, apiinfodem0_.url as url13_0_0_ from api_info_demo apiinfodem0_ where apiinfodem0_.id=?
Optional[ApiInfoDemo(id=5, title=xxooxx, tag=null, url=null, method=null, requestHeader=null, markdownInfo=hwllorld world, requestJson=null, requestParam=null, response=null, responseHeader=null, gmtCreate=null, gmtModified=2020-12-15 00:00:00.0)]

2020-12-15 10:14:16.653 INFO 5260 — [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit ‘default’

2020-12-15 10:14:16.655 INFO 5260 — [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService ‘applicationTaskExecutor’
2020-12-15 10:14:16.655


query 查询的写法

@Query(value = "select a from ApiInfoDemo a where  a.title like :#{#title==null|| #title.isEmpty()?'%': '%'+#title+'%'} ")   List
queryTitleLike(@Param("title") String title, Pageable pageable);

转载地址:http://kyyzi.baihongyu.com/

你可能感兴趣的文章
在类中定义enum实现整数常量功能
查看>>
suse11通过安装最新内核可以上网的经验
查看>>
SUSE静态配置IP成功上网
查看>>
通过sleep让程序等待外部条件改变
查看>>
通过等待键盘输入让程序等待外部条件改变
查看>>
通过限制循环次数来避免死循环
查看>>
ADO连接字符串
查看>>
字符数组的位置决定程序能否成功执行--不明白
查看>>
拷贝代码时没有仔细检查,导致误修改了函数参数
查看>>
MySQL批量导入数据SQL语句(CSV数据文件格式)
查看>>
ADO连接Oracle
查看>>
遍历Windows系统中所有进程的名字(*.exe)
查看>>
进程看门狗
查看>>
线程看门狗
查看>>
调试代码的宏定义
查看>>
创建、重命名文件
查看>>
文件大小保护
查看>>
删除指定目录下所有文件及目录
查看>>
XDR-从文件空间解码整数
查看>>
XDR-.x文件的简单使用
查看>>