我想将简单查询的结果集映射到我的域对象,但是当我使用该into()方法时,某些属性只是null
Result<DepartmentRecord> fetch = dsl.selectFrom(DEPARTMENT).fetch();
List<Department> collect = fetch.stream().map(f -> new Department(f.getId(), f.getName())).collect(Collectors.toList());
System.out.println("collect: " + collect);
// WORKS
// prints: collect: [Department [id=1, name=Mooh], Department [id=2, name=Mooh2]]
List<Department> into = fetch.into(Department.class);
System.out.println("into: " + into);
// DOESN'T WORK: name is null
// prints: into: [Department [id=1, name=null], Department [id=2, name=null]]
这是我的域对象/JPA 实体:
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Department {
@Id
@GeneratedValue
private int id;
private String name;
}
我做错了什么?
使用 Spring Boot 2.1.8、jOOQ 3.11.0、OpenJDK 11
MMTTMM
相关分类