我有一个从另一个继承的对象,并且我试图将其保存(持久)在数据库中。问题是当我尝试时,出现此错误:
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
最佳答案
请这样注释您的实体
@Table(name = "derogation", schema = "calamar")