Spring Data JPA将动态列名称作为参数传递给查询

时间:2019-06-17 14:37:38

标签: spring spring-data-jpa spring-data microservices

我的表emp的列为emp_name,emp_desc,emp_age,emp_country,emp_pincode。

我正在使用Spring数据Jpa进行数据库操作。

 @Repository
 public interface EmpRepository extends JpaRepository<Emp, String> {}

和empRepository.findAll();从emp表中触发选择*。

但是我有如下要求

客户端应用程序将传递列名以在方法中选择作为参数,而我只想获取Jpa中的列名而不是Findall()。

如何在Jpa中实现这一目标?

1 个答案:

答案 0 :(得分:0)

尝试这个   根据emp_name获取员工详细信息       empRepository.findByEmpName(String empName);