From 4d7706073c8e1d34d43817cee0758ecc5b6c962c Mon Sep 17 00:00:00 2001 From: wu <303054730@qq.com> Date: Wed, 13 Nov 2024 07:57:09 +0800 Subject: [PATCH] changed --- .../src/main/java/com/lk/demo/UserRepository.java | 8 ++++---- .../src/main/resources/application.yml | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/examples/chapter06/spring-boot-jpa-demo/src/main/java/com/lk/demo/UserRepository.java b/examples/chapter06/spring-boot-jpa-demo/src/main/java/com/lk/demo/UserRepository.java index b7a6ea0..b02bf85 100644 --- a/examples/chapter06/spring-boot-jpa-demo/src/main/java/com/lk/demo/UserRepository.java +++ b/examples/chapter06/spring-boot-jpa-demo/src/main/java/com/lk/demo/UserRepository.java @@ -7,15 +7,15 @@ import org.springframework.data.repository.query.Param; import java.util.List; public interface UserRepository extends JpaRepository { + List findByNameLikeOrderByAgeDesc(String name); @Query("Select u from User u where u.name like %?1% order by u.age desc") List abcd(String name); - @Query("Select u from User u where u.name like %:name% order by u.age desc") - List dcba(@Param("name") String name); + @Query("Select u from User u where u.name like %:userName% order by u.age desc") + List dcba(@Param("userName") String name); - @Query(value = "Select * from Users u where u.name like %?1% order by u.age desc", nativeQuery = true) + @Query(value = "Select * from Users u where u.name like %?1% order by u.age desc", nativeQuery = true) List queryUsersByName(String name); - } diff --git a/examples/chapter06/spring-boot-jpa-demo/src/main/resources/application.yml b/examples/chapter06/spring-boot-jpa-demo/src/main/resources/application.yml index 48f91fb..9565f58 100644 --- a/examples/chapter06/spring-boot-jpa-demo/src/main/resources/application.yml +++ b/examples/chapter06/spring-boot-jpa-demo/src/main/resources/application.yml @@ -16,6 +16,7 @@ # format_sql: true # 保持原样,用于格式化SQL输出 + spring: jackson: property-naming-strategy: SNAKE_CASE # 驼峰转下划线 @@ -37,4 +38,9 @@ spring: defer-datasource-initialization: true database-platform: org.hibernate.dialect.H2Dialect hibernate: - ddl-auto: update \ No newline at end of file + ddl-auto: update + + +my: + file: + path: /tmp \ No newline at end of file