我的休眠程序有问题。我已经删除并重写了该类,但仍然抛出相同的错误。我没有在此表中声明cod_modulo,即使我删除了一对多参数,仍然会引发相同的错误。我什么都不懂。
这里引用了这些类。它还具有所有元素的getter和setter和空的公共构造函数。
模类
@Entity
@Table(name="modulo")
public class Modulo implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@SequenceGenerator(name = "SEQ_MODULO", sequenceName = "SEQ_MODULO", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_MODULO")
private int cod_modulo;
@Column(name = "ancho_modulo")
private Double ancho_modulo;
@Column(name = "largo_modulo")
private Double largo_modulo;
@Column(name = "alto_modulo")
private Double alto_modulo;
@Column(name = "orden")
private Integer orden;
@ManyToOne(cascade = CascadeType.DETACH, targetEntity = Lineal.class, fetch = FetchType.EAGER)
@JoinColumn(name = "cod_lineal", referencedColumnName = "cod_lineal")
private Lineal lineal;
//@OrderBy
@JsonProperty(access = Access.WRITE_ONLY)
@OneToMany(mappedBy = "modulo", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private Set<Balda> baldas;
直系类
@Entity
@Table(name="lineal")
public class Lineal implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@SequenceGenerator(name = "SEQ_LINEAL", sequenceName = "SEQ_LINEAL", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_LINEAL")
private int cod_lineal;
@ManyToOne(cascade = CascadeType.DETACH, targetEntity = Seccion.class, fetch = FetchType.EAGER)
@JoinColumn(name = "cod_seccion", referencedColumnName = "cod_seccion")
private Seccion seccion;
@JsonProperty(access = Access.WRITE_ONLY)
@OneToMany(mappedBy = "lineal", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private Set<Modulo> modulos;
@Column(name = "refrigerado")
private Boolean refrigerado;
@Column(name = "horizontal")
private Boolean horizontal;
@Column(name = "pos_x")
private Double pos_x;
@Column(name = "pos_y")
private Double pos_y;
错误:
映射异常:无法在org.hibernate.mapping.Table(lineal)及其相关的超表和辅助表中找到逻辑名称为cod_modulo的列
最佳答案
尝试为您的cod_modulo属性添加@Column,如下所示:
@Id
@SequenceGenerator(name = "SEQ_MODULO", sequenceName = "SEQ_MODULO", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_MODULO")
@Column(name = "cod_modulo")
private int cod_modulo;