[英]Spring Boot Dynamic field
How to handle the dynmaic fields creation in ui and mapping it to the backend in the spring boot.如何处理 ui 中的动态字段创建并将其映射到 spring boot 中的后端。 I have all the fields in the mysql and data storage in mongo.我有mysql中的所有字段和mongo中的数据存储。 How to map with pojo entity to save and retrive.如何与 pojo 实体映射以保存和检索。
I have tried with the pojo and without pojo mpaiings using spring jpa.我已经尝试使用 spring jpa 使用 pojo 而没有使用 pojo mpaiings。
"dynamic" fields? “动态”字段? Do you mean adding columns on the flight?您的意思是在航班上添加专栏吗? This is looks like LOV (anti-)pattern that could be mapped to an entity (id, owner_id, key, value) where all values will be store as string, the key will be your field name, id an IDENTITY, and owner_id the FK on the other entity owning the set of (key, value).这看起来像是可以映射到实体(id、owner_id、键、值)的 LOV(反)模式,其中所有值都将存储为字符串,键将是您的字段名称,id 是 IDENTITY,owner_id 是FK 在拥有(键,值)集合的另一个实体上。
you UI consume a rest api that returns a list of fields to display.您的 UI 使用 rest api 返回要显示的字段列表。 Up to you to choose how to store it: In a relational database, you need to have a principal table and a table that store the fields and then you can retrieve it by a join.由您选择如何存储它:在关系数据库中,您需要有一个主表和一个存储字段的表,然后您可以通过连接检索它。 In a mongodb, you can have a document, the fields will be a part of it as a json array and then you can retrive it by parsing the json.在 mongodb 中,你可以有一个文档,字段将作为 json 数组的一部分,然后你可以通过解析 json 来检索它。
Is that you want to do?那是你想做的吗? The how depends on what framework you use (I see Spring) (So Spring data works both with a mongodb and a mysql)如何取决于您使用的框架(我看到 Spring)(因此 Spring 数据适用于 mongodb 和 mysql)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.