arraylist - 如何保存列表的jpa列表
问题描述
我想在我的春季项目中保存列表数据列表
我的项目前面是vue
像这样的前端发送数据结构
data=[[{}],[{},{}],[{},{}]]
这是我的数据
"option1": [
{
"firstOption": "s",
"quantity": 1,
"option2": [
[
{
"optionsDetail": "ss",
"leaseType": "1",
"needType": 10,
"monthlyPayment": 4412,
"total": 158832,
"prePayment": "0",
"state": "-",
"used": true
},
{
"optionsDetail": "ss",
"leaseType": "1",
"needType": 11,
"monthlyPayment": 4412,
"total": 158832,
"prePayment": "0",
"state": "-",
"used": true
}
],
[
{
"optionsDetail": "dd",
"leaseType": "1",
"needType": 10,
"monthlyPayment": 88,
"total": 3168,
"prePayment": "0",
"state": "-",
"used": true
},
{
"optionsDetail": "dd",
"leaseType": "1",
"needType": 11,
"monthlyPayment": 88,
"total": 3168,
"prePayment": "0",
"state": "-",
"used": true
}
],
[
{
"optionsDetail": "f",
"leaseType": "1",
"needType": 10,
"monthlyPayment": 4412,
"total": 158832,
"prePayment": "0",
"state": "-",
"used": true
},
{
"optionsDetail": "f",
"leaseType": "1",
"needType": 11,
"monthlyPayment": 4412,
"total": 158832,
"prePayment": "0",
"state": "-",
"used": true
}
]
],
"itemIdx": 165
},
{
"firstOption": "aa",
"quantity": 1,
"option2": [
[
{
"optionsDetail": "sdf",
"leaseType": "1",
"needType": 10,
"monthlyPayment": 1000000,
"total": 1000000,
"prePayment": "0",
"state": "-",
"used": true
},
{
"optionsDetail": "sdf",
"leaseType": "1",
"needType": 11,
"monthlyPayment": 1000000,
"total": 1000000,
"prePayment": "0",
"state": "-",
"used": true
}
],
[
{
"optionsDetail": "ee",
"leaseType": "1",
"needType": 10,
"monthlyPayment": 25885,
"total": 931860,
"prePayment": "0",
"state": "-",
"used": true
},
{
"optionsDetail": "ee",
"leaseType": "1",
"needType": 11,
"monthlyPayment": 25885,
"total": 931860,
"prePayment": "0",
"state": "-",
"used": true
}
]
],
"itemIdx": 108
}
我想使用弹簧数据 jpa 保存
一种方法是
@JsonIgnoreProperties(ignoreUnknown = true)
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "opt_idx" )
private List<RentTypeList> option2 = new ArrayList<>();
其他 @ElementCollection(fetch=FetchType.EAGER) 私有列表 option2 = new ArrayList<>();
我使用两种方式但是会发生错误
JSON parse error: Cannot deserialize instance of `EntityList` out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException:
Cannot deserialize instance of `option2` out of START_ARRAY token
at [Source: (PushbackInputStream); line: 9, column: 13] (through reference chain:
EntityList["option1"]->java.util.ArrayList[0]->option2["option2"]->java.util.ArrayList[0])]
我该如何改变?
解决方案
推荐阅读
- swift - 在 SwiftUI Document App 中,如何从函数中保存文档
- python - augemtation 错误,tensorflow.python.keras.preprocessing.image.ImageDataGenerator
- python - 如何在 Superset 中以编程方式向角色添加权限?
- istio - 多集群 istio 而不暴露集群之间的 kubeconfig
- sequelize.js - Sequelize 不使用 findOrCreate 将内容写入数据库
- python - Python Beautiful Soup Webscraping:无法显示完整的表格
- forms - 在单个蚂蚁设计 Form.Item 上放置一个图标和一个输入
- crystal-lang - Crystal:检测字典插入是否覆盖键,但没有哈希两次
- python - 提及时 discord.py 发送前缀
- c# - ActionResult 参数为空