简体   繁体   English

Spring Boot 动态字段

[英]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.

相关问题 在Spring Boot中生成动态查询 - Generating dynamic query in spring boot 如何使用 spring 引导从数据库 MYSQL 数据库创建动态菜单 - How to create Dynamic Menu from Database MYSQL database with spring boot 有没有办法使用 jdbc 在 spring 启动应用程序中开发动态 sql 查询? - Is there a way to develop dynamic sql query in spring boot app with jdbc? 尝试在 Spring Boot 和 Hibernate 中保存对象的字段错误 - Field error trying to save object in Spring Boot & Hibernate Spring 修改实体字段时未更新数据库中的引导表 - Spring boot tables in database not updated when entity field is modified Spring boot jpa/hibernate 遇到列类型错误(json字段) - Spring boot jpa / hibernate wrong column type encounter (json field) 如何在 Spring Boot 的 MySql 查询中使用“LIKE field var%”中的变量? - How to use variable in 'LIKE field var%' in MySql query of Spring Boot? Spring Boot Hibernate 类型异常创建带有 JSON 字段的表 - Spring boot hibernate types exception creating table with JSON field 春季启动-com.mysql.jdbc。春季启动exceptions.jdbc4.MySQLSyntaxErrorException:“字段列表”中的未知列“ customer0_.email” - spring boot - com.mysql.jdbc.spring boot exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'customer0_.email' in 'field list' Spring 引导:如何使用谓词创建涉及“join”和“group by”的动态查询 - Spring Boot: How to create dynamic query involving 'join' and 'group by' using predicate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM