Hibernate 4 “unable to find column” error

package it.company.tserver.beans.indicatori.ondemand.persistent;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

@Entity
@Table(name = "INDICATORS_OD")
@NamedQueries( { 
    @NamedQuery(name = "IndicatorOD.getAllIndicators", query = "SELECT o FROM IndicatorOD o ORDER BY o.description ASC"), 
    @NamedQuery(name = "IndicatorOD.getIndicatorsForType", query = "SELECT o FROM IndicatorOD o WHERE o.type = :type ORDER BY o.description ASC"), 
    @NamedQuery(name = "IndicatorOD.getReqTemplate", query = "SELECT o from IndicatorOD j LEFT JOIN j.reqTemplate o where j.codIndicator = :cod ORDER BY o.orderForm ASC"),
    @NamedQuery(name = "IndicatorOD.getRespTemplate", query = "SELECT o from IndicatorOD j LEFT JOIN j.respTemplate o where j.codIndicator = :cod ORDER BY o.orderForm ASC")
})

public class IndicatorOD implements Serializable {

    private static final long serialVersionUID = 1626218826909078278L;

    public enum IndicatorTypes {
        INDICATOROD, RENDOBBCALC
    }

    private String codIndicator;
    private String description;
    private IndicatorTypes type;

    private Set<IndicatorODTemplate> reqTemplate = new HashSet<IndicatorODTemplate>();
    private Set<IndicatorODRespTemplate> respTemplate = new HashSet<IndicatorODRespTemplate>();


    @Id
    @Column(name = "CODE_IND")
    public String getCodIndicator() {
        return codIndicator;
    }
    public void setCodIndicator(String codIndicator) {
        this.codIndicator = codIndicator;
    }


    @Column(name = "DESCRIPTION")
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }


    @Column(name = "TYPE_IND")
    @Enumerated(EnumType.STRING)
    public IndicatorTypes getType() {
        return type;
    }
    public void setType(IndicatorTypes type) {
        this.type = type;
    }


    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @OrderBy("orderForm ASC")
    @JoinColumn(name = "CODE_IND", referencedColumnName = "CODE_IND")
    public Set<IndicatorODTemplate> getReqTemplate() {
        return reqTemplate;
    }


    public void setReqTemplate(Set<IndicatorODTemplate> template) {
        this.reqTemplate = template;
    }
    

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @OrderBy("orderForm ASC")
    @JoinColumn(name = "CODE_IND", referencedColumnName = "CODE_IND")
    public Set<IndicatorODRespTemplate> getRespTemplate() {
        return respTemplate;
    }


    public void setRespTemplate(Set<IndicatorODRespTemplate> respTemplate) {
        this.respTemplate = respTemplate;
    }
}

this deploys in jboss 4 with hibernate 3, in jboss 7.1 with hibernate 4 it gives an error :

org.hibernate.MappingException: Unable to find column with logical name: CODE_IND in org.hibernate.mapping.Table(INDICATORS_OD) and its related supertables and secondary tables

the joincolumn is on the same table, it’s not a foreign key to another table, what could be the problem ?

the table in oracle is :

  CREATE TABLE "TSERVER"."INDICATORS_OD" 
   (	"CODE_IND" VARCHAR2(5 BYTE) NOT NULL ENABLE, 
	"DESCRIPTION" VARCHAR2(50 BYTE), 
	"TYPE_IND" VARCHAR2(25 BYTE), 
	 CONSTRAINT "PK_INDICATOR_OD" PRIMARY KEY ("CODE_IND")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "TSDATA"  ENABLE
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "TSDATA" ;

I’m sorry, but Hibernate 4 is pretty old already (5+ years) and is not maintained anymore. Unless you update to a more recent version that is supported, we can’t really help you much.

is there any hibernate annotations syntax validator like for html say, for ides like eclipse/intellij that I think they can display say java annotations errors or needed ones ? where you could select hibernate versions, independent of db schema, for say silly mistakes.

I think with Eclipse you can use JBoss Tools for this purpose, but behind the scenes, what is happening, is that it just compiles the code and tries to build the model with a certain Hibernate version.

hmm so it could be possibile with jboss tools