我需要通过加入多个表来获取 4 列。我已经创建了查询。但是如何将结果集映射到不是实体的 pojo 并且我想使用 Spring Data JPA。
有人可以帮忙吗?
谢谢!
编辑 自定义 POJO 类:
`
@Data
@AllArgsConstructor
@NamedNativeQuery(name = CustomPojo.retriveCustomPojo
query = Constants.CUSTOM_QUERY, resultSetMapping = CustomDataMapping")
@SqlResultSetMapping(name = "CustomDataMapping",
classes = {
@ConstructorResult(
targetClass = CustomPojo.class,
columns = {
@ColumnResult(name = "NAME"),
@ColumnResult(name = "TYPE"),
@ColumnResult(name = "TITLE"),
@ColumnResult(name = "DESCRIPTION")
}
)
}
)
public class CustomPojo implements Serializable {
private static final long serialVersionUID = 1L;
private String name
private String type;
private String title;
private String description;
}
`