【发布时间】:2018-06-02 09:00:39
【问题描述】:
我需要通过查询多个主键来获取多条记录。例如,从Oracle DB 获取多个Employee 记录
具有基于多个主键 employee_id = {1,2,3} 的 EmployeeId、EmployeeName 字段,这将导致 3 Employee 记录,所有这些都在单个 DB 会话中。
我可以一一做:
Optional<EmployeeBean> eb = employeeRepo.findByEmployeeId(Id);
这里employeeRepo 扩展CrudRepository<Employee, Long>
是否可以使用Spring 5 中的主键列表进行批量记录提取?
【问题讨论】:
-
你需要
select .. from .. where id in (1, 2, 3)之类的东西吗?
标签: spring hibernate spring-data-jpa spring-batch