hibernate 继承实体类问题 SQL Error: 1054, SQLState: 42S22 SqlExceptionHelper : Unknown column ‘dtype’

基本环境:

springboot + hibernate

实体类

package com.example.bifrost.entry.db;

import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;

//@MappedSuperclass
@Table(name = "DB_Config")
@Entity //标注实体类 ********************
@Data
public class  DB implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;
    private String type ;
    private String config ;
    private boolean valid ;
}

如果有子类实体类继承了父类实体类在调用 crud接口的save方法时

会出现

Hibernate: 
    insert 
    into
        db_config
        (config, type, valid, dtype) 
    values
        (?, ?, ?, 'DB')
2019-08-08 18:26:33.086  WARN 19684 --- [nio-8080-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1054, SQLState: 42S22
2019-08-08 18:26:33.086 ERROR 19684 --- [nio-8080-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper   : Unknown column 'dtype' in 'field list'

提示缺少 dtype字段,dtype字段是用来区分类的

hibernate 继承实体类问题 SQL Error: 1054, SQLState: 42S22 SqlExceptionHelper : Unknown column ‘dtype’_第1张图片

去掉继承该父类的子类的@Entity注解就不会出现该问题,如果不能去除可添加dtype字段。 

你可能感兴趣的:(hibernate)