0

Ive having problems with my hibernate program. I have deleted and rewrited the class and still throws same error. I dont have declared the cod_modulo in this table, and even if i remove the one to many parameter, still throws same error. I dont understand anything.

Here the classes referenced. It also has getters and setters for all elements and the empty public constructor.

The modulo class


@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;


The lineal class

@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;

The error:

Mapping exception: Unable to find column with logical name: cod_modulo in org.hibernate.mapping.Table(lineal) and its related supertables and secondary tables

  • But the lineal table has the cod_lineal field, and the cod_modulo corresponds to the primary key of the modulo table. 1 lineal has many modulo, so i cant put a cod_modulo field in the lineal class. I dont understand ur tip. – 8BytesWord Oct 25 '19 at 16:07
  • Does table `Modulo` have a column `cod_lineal` as required by `@JoinColumn(name = "cod_lineal", referencedColumnName = "cod_lineal")`? – Curiosa Globunznik Oct 25 '19 at 17:55
  • Possible duplicate of [org.hibernate.MappingException: Unable to find column with logical name](https://stackoverflow.com/questions/8624633/org-hibernate-mappingexception-unable-to-find-column-with-logical-name) – Curiosa Globunznik Oct 25 '19 at 17:55

1 Answers1

0

Try adding @Column for your cod_modulo property like so:

  @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;
sanemain
  • 139
  • 1
  • 13