本文共 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.655query 查询的写法
@Query(value = "select a from ApiInfoDemo a where a.title like :#{#title==null|| #title.isEmpty()?'%': '%'+#title+'%'} ") ListqueryTitleLike(@Param("title") String title, Pageable pageable);
转载地址:http://kyyzi.baihongyu.com/