sql - 在 Spring Boot 实体类中使用 desc 作为字段名
问题描述
尽管遵循了正确的过程模型,但没有为以下模型创建表
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Integer pid;
String name;
String desc;
double price;
}
解决方案
所以我为 JPA 创建了一个实体类,其中有一个字段名称 desc。我使用的是 MySQL 数据库。但由于某种原因,我收到以下错误。 该模型
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Integer pid;
String name;
String desc;
double price;
}
后来我更改了字段名称,整个事情都在工作。ORM 会自动创建表。 有效的更新模型
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Integer pid;
String name;
String description;
double price;
}
推荐阅读
- python - Python Flask 应用程序未重定向
- python - 筛选数据透视表
- javascript - Amcharts -Treemap图表如何获取工具提示值和点击事件
- javascript - 传递给Vuex模块的函数后的Vue TypeScript未定义值
- powershell - 如何使用 Nullable
Powershell 中的类型? - redisson - 使用 Redisson 批处理时,操作的顺序是否有保证?
- php - 为什么 Ajax 代码没有发布到 pho 文件?
- kubernetes - 如何在 OpenShift pod YAML 配置中绑定多个端口?
- django - 如何在不使用 docker-compose.yml 的情况下为多个容器创建单个 Dockerfile?
- python-3.x - 一旦 numPy 数组的元素达到某个值,如何设置执行命令的条件?