This commit is contained in:
wu 2024-11-13 07:57:09 +08:00
parent 5c6259fb8a
commit 4d7706073c
2 changed files with 11 additions and 5 deletions

View File

@ -7,15 +7,15 @@ import org.springframework.data.repository.query.Param;
import java.util.List; import java.util.List;
public interface UserRepository extends JpaRepository<User, Long> { public interface UserRepository extends JpaRepository<User, Long> {
List<User> findByNameLikeOrderByAgeDesc(String name); List<User> findByNameLikeOrderByAgeDesc(String name);
@Query("Select u from User u where u.name like %?1% order by u.age desc") @Query("Select u from User u where u.name like %?1% order by u.age desc")
List<User> abcd(String name); List<User> abcd(String name);
@Query("Select u from User u where u.name like %:name% order by u.age desc") @Query("Select u from User u where u.name like %:userName% order by u.age desc")
List<User> dcba(@Param("name") String name); List<User> 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<User> queryUsersByName(String name); List<User> queryUsersByName(String name);
} }

View File

@ -16,6 +16,7 @@
# format_sql: true # 保持原样用于格式化SQL输出 # format_sql: true # 保持原样用于格式化SQL输出
spring: spring:
jackson: jackson:
property-naming-strategy: SNAKE_CASE # 驼峰转下划线 property-naming-strategy: SNAKE_CASE # 驼峰转下划线
@ -38,3 +39,8 @@ spring:
database-platform: org.hibernate.dialect.H2Dialect database-platform: org.hibernate.dialect.H2Dialect
hibernate: hibernate:
ddl-auto: update ddl-auto: update
my:
file:
path: /tmp