【发布时间】:2022-01-22 20:37:06
【问题描述】:
" 选择问题。*, question_option.id from question left join question_option on question_option.question_id = question.id; "
如何将获得的结果映射到实体。所以预期的结果应该是 谁能给出上面得到结果的示例代码
{
"id": 2655,
"type": "MCQSingleCorrect",
"difficultyLevel": "Advanced",
"question": "Which country are you from?",
"answer": null,
"marks": 1.5,
"negativeMarks": 0.5,
"hint": null,
"explanation": null,
"booleanAnswer": null,
"passage": null,
"isPassageQuestion": null,
"audioFile": null,
"videoFile": null,
"questionFiles": [],
"tags": [],
"updatedAt": "2021-12-21T11:57:03.229136Z",
"createdAt": "2021-12-21T11:57:03.229098Z",
"questionOptions": [
{
"id": 2719,
"option": "India",
"index": 1,
"correct": false,
"blank": null
},
{
"id": 2720,
"option": "Newzealand",
"index": 1,
"correct": false,
"blank": null
},
{
"id": 2721,
"option": "England",
"index": 1,
"correct": true,
"blank": null
},
{
"id": 2722,
"option": "Australia",
"index": 1,
"correct": false,
"blank": null
}
]}
【问题讨论】:
-
我不明白你的问题。您想要 JSON 作为结果还是 JPA 实体?
-
我希望它在 JPA 实体中。如果可能的话,你也可以说 JSON 吗?
-
为什么需要 JPA 实体作为生成 JSON 的中间格式?使用jOOQ直接生成JSON会简单得多……
-
我想要 JPA 实体,因为在获得查询结果后,有时我需要对数据做一些额外的操作。但是您能否在答案部分中发布代码以直接从 jooq 本身获取 Jason 结果。
标签: mysql spring-boot jooq