Spring Boot 如何在Sping Boot 实体类中使用oracle关键字“desc”作为字段名

0md85ypi  于 2023-01-05  发布在  Spring
关注(0)|答案(1)|浏览(174)

尽管遵循了正确的过程,但未为以下型号创建表型号

@AllArgsConstructor
    @NoArgsConstructor
    @Data
    @Entity
    public class Product {
    
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        Integer pid;
    
        String name;
        String desc;
        double price;
    }

z6psavjg

z6psavjg1#

我在为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;
}

相关问题