简体   繁体   English

休眠子类的字段列表中的未知列

[英]hibernate child class unknown column in in field list

So i'm writing a platform that consists of teams with researchers ( = 'onderzoeker' in Dutch ). 因此,我正在编写一个由研究人员组成的平台(=荷兰语中的“ onderzoeker”)。 Researchers inherit from Role because they need to be able to login with Spring security. 研究人员从Role继承,因为他们需要能够使用Spring安全性登录。 Left out all the getters and setters but they are there! 省略了所有的获取器和设置器,但是它们在那里! Thanks in advance :) 提前致谢 :)

ERROR 错误

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'onderzoeke0_.onderzoekerid' in 'field list'

Class Onderzoeker Onderzoeker类别

 Class onderzoeker




@SuppressWarnings("serial")
@Entity
@DiscriminatorValue(value = "Onderzoeker")
public class Onderzoeker extends Rol {

@Column(name="onderzoekerid")
private int onderzoekerid;

@Column(name="onderzoekernaam")
protected String onderzoekernaam;

@Column(name="onderzoekervoornaam")
protected String onderzoekervoornaam;

@ManyToOne
@JoinColumn(name="onderzoekerteamid")
protected Team team;


    @Override
    public String getType() {
        return "Onderzoeker";
    }

}

Class Role from which Onderzoeker inherits Onderzoeker继承的类角色

package be.odisee.oxyplast.domain;


@DiscriminatorOptions(force=true)
@Entity
@Table(name="rollen")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE )
@DiscriminatorColumn(name="type",
discriminatorType=DiscriminatorType.STRING)
@DiscriminatorValue("Rol")
public abstract class Rol implements Serializable {

@Id
@Column(name="id")
@GeneratedValue(strategy=GenerationType.AUTO)
protected int id;



@Column
protected String status;

@Column(unique=true)
@Index(name="IRol_usernaam",columnNames="usernaam")
protected String usernaam;

@ManyToOne
@JoinColumn(name="sessie_id")
protected Sessie sessie;

@ManyToOne
@JoinColumn(name="persoon_id")
protected Persoon persoon;

public Rol(){}

public Rol(String status, String usernaam, Sessie sessie, Persoon persoon) {
    this.status = status;
    this.usernaam = usernaam;
    this.sessie = sessie;
    this.persoon = persoon;
}

public Rol(int id, String status, String usernaam, Sessie sessie, Persoon persoon) {
    this.id = id;
    this.status = status;
    this.usernaam = usernaam;
    this.sessie = sessie;
    this.persoon = persoon;
}

Well this needs to be enough the resolve the question. 那么这足以解决问题。 And yes the database is correct, it needs to be something else 是的,数据库是正确的,它必须是其他东西

I have the same problem, I finilly found both parent and child class need public default constructor! 我有同样的问题,我最终发现父子类都需要公共默认构造函数!

parent class: 家长班:

@MappedSuperclass
public abstract class Order {

    public Order() {

    }
}

child class: 子班:

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Table(name="ItemOrder")
public class ItemOrder extends Order {

public ItemOrder() throws Exception {
    super();        
}

I hope this answer helps someone. 我希望这个答案对某人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Hibernate:字段列表中的未知列 - Hibernate: Unknown column in field list 休眠:字段列表中的未知列 - Hibernate : Unknown column in field list Hibernate:MySQLSyntaxErrorException:'字段列表'中的未知列'____' - Hibernate : MySQLSyntaxErrorException: Unknown column ' ____ ' in 'field list' java hibernate“字段列表”中的未知列“” - java hibernate Unknown column ' ' in 'field list' Spring & Hibernate:“字段列表”中的未知列,但列名匹配 - Spring & Hibernate: Unknown Column in 'field list' but column name is matching “Hibernate中的数据库加密”在“字段列表”中返回未知列'encryptedBody' - “DataBase encryption in Hibernate” returns Unknown column 'encryptedBody' in 'field list' org.hibernate.util.JDBCExceptionReporter-“字段列表”中的未知列“ postalCode” - org.hibernate.util.JDBCExceptionReporter - Unknown column 'postalCode' in 'field list' “字段列表”中的未知列“ 1” - Unknown column '1' in 'field list' Hibernate:线程“主”中的异常org.hibernate.exception.SQLGrammarException:“字段列表”中的未知列“ DTYPE” - Hibernate: Exception in thread “main” org.hibernate.exception.SQLGrammarException: Unknown column 'DTYPE' in 'field list' J2EE JPA和类继承-未知列“字段列表” - J2EE JPA and class inheritance - Unknown column 'field list'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM