Hibernate无法在继承的类上提取ResultSet

时间:2016-07-12 14:25:36

标签: java hibernate

我有一个从另一个继承的对象,我试图在我的数据库中保存(持久化)它。问题是,当我尝试时,我收到了这个错误:

javax.persistence.PersistenceException: 
org.hibernate.exception.SQLGrammarException: could not extract ResultSet

我不知道我做错了什么..这是我的课程:

@Entity
@Table(name = "calamar.derogation")
public class Derogation 
{
    @Id 
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "derogation_seq_gen")
    @SequenceGenerator(name = "derogation_seq_gen", sequenceName = "calamar.derogation_id_seq",initialValue = 1, allocationSize = 1)
    private int id;

    @OneToMany(mappedBy="derogation", cascade = CascadeType.ALL, orphanRemoval=true, fetch = FetchType.EAGER)
    @OrderBy("id")
    private Set<DerogationFille> listDerogationFille;

    [...]
}

@Entity
public abstract class DerogationFille{

    @Id 
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    protected int id;

    @ManyToOne
    protected Derogation derogation;
    [...]
}

@Entity
@Table(name = "calamar.derogationlinux")
public class DerogationLinux extends DerogationFille
{

    private String chemin;
    private String userFam;
    private String serveur;
    @Column(name="typederogation")
    private String type;
    [...]
}

我在这方面得到了错误:

entityManager.getTransaction().begin();

entityManager.persist(derogation);

编辑1 ##

我没有正确看待我,我也有这个错误,我认为这是主要问题

ERROR: relation "hibernate_sequence" does not exist

1 个答案:

答案 0 :(得分:1)

请注释您的实体

@Table(name = "derogation", schema = "calamar")