spring - 是否可以从 jpa/hibernate 获取数据,而无需在 Spring Boot 中定义实体或模型?
问题描述
是否可以从 jpa/hibernate 获取数据,而无需在 Spring Boot 中定义实体或模型?如果可能的话,怎么做?谢谢你...
解决方案
是的,它可能适用于您首先阅读的服务器端和数据库
对于 restful,您必须使用 RequestEntity<> 来获取没有模型的字段并从 JSON 发送或接收数据。
// Field class is a response and this is not model class
public class Field{
private String name;
//getter and seter
}
@PostMapping("/test")
public void getFields(RequestEntity<Map<String,String>> entity){
Field field = new Field();
field.setName(entity.getBody().get("name"));
System.out.println(field);
}
推荐阅读
- multiplication - Netcdf 文件的乘法和加法
- flutter - 如何在flutter中缓存firestore文档?
- pdf - 为什么将pdf转换为jpeg时会发现更多内容?
- javascript - 无法从 React js 表单呈现 Django 视图函数
- javascript - 我无法使用 javascript 在 type="time" 字段中写入值
- python - 测试 Python 点击命令异常
- python - 使用 python,我无法从 Google Drive API v3 访问共享驱动器文件夹
- c++ - 如何在OpenGL中绘制两个或多个三角形?
- node.js - Sequelize:在表中硬删除和插入
- regex - 将字符串中的 Pascal 大小写更改为蛇大小写