如何使用SqlResultSetMappings
或ResultTransformer
返回json对象而不是json字符串数组。这是我在使用SqlResultSetMappings
或ResultTransformer
[
"Mel Bale ",
"B.A.",
"Interior Designer",
"Daosa",
"n/a"
]
我想要的是这样
{
"name":"Mel Bale ",
"qualification":"B.A.",
"Job":"Interior Designer",
"location":"Daosa",
"phone":"n/a"
}
答案 0 :(得分:0)
您需要像这样定义@SqlResultSetMappings,以便将数据映射为JSON
@SqlResultSetMapping(
name = "findAllDataMapping",
classes = @ConstructorResult(
targetClass = Sample.class,
columns = {
@ColumnResult(name = "name"),
@ColumnResult(name = "qualification"),
@ColumnResult(name = "Job"),
@ColumnResult(name = "location"),
@ColumnResult(name = "phone")
}
)
)