0

当我执行查询以在 Hibernate 中保存对象时-生成的查询是错误的-下面是休眠生成的查询-

select sintranhis_.SINID, sintranhis_.SINDDT as SINDDT3_, sintranhis_.SINDES as SINDES3_, sintranhis_.SINTIME as SINTIME3_, sintranhis_.SINTNO as SINTNO3_ from ERPDSS3.SINTRAN_HISTORY  sintranhis_ where sintranhis_.SINID=?

下面是 SINTRAN_HISTORY 类 -

public class SottranHistory extends Persistent_Model implements java.io.Serializable {


     private SottranHistoryId id;
     private Stpmast stpmast;
     private String sotdes;
     private BigDecimal sottno;
     private Date sotddt;
     private Timestamp sottime;

    public SottranHistory() {
    }


    public SottranHistory(SottranHistoryId id, Stpmast stpmast) {
        this.id = id;
        this.stpmast = stpmast;
    }
    public SottranHistory(SottranHistoryId id, Stpmast stpmast, String sotdes, BigDecimal sottno, Date sotddt, Timestamp sottime) {
       this.id = id;
       this.stpmast = stpmast;
       this.sotdes = sotdes;
       this.sottno = sottno;
       this.sotddt = sotddt;
       this.sottime = sottime;
    }

     @EmbeddedId


    @AttributeOverrides( {
        @AttributeOverride(name="sottyp", column=@Column(name="SOTTYP", nullable=false, length=12) ), 
        @AttributeOverride(name="sotid", column=@Column(name="SOTID", nullable=false, precision=6, scale=0) ) } )
    public SottranHistoryId getId() {
        return this.id;
    }

    public void setId(SottranHistoryId id) {
        this.id = id;
    }

@ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="SOTTYP", nullable=false, insertable=false, updatable=false)
    public Stpmast getStpmast() {
        return this.stpmast;
    }

    public void setStpmast(Stpmast stpmast) {
        this.stpmast = stpmast;
    }


    @Column(name="SOTDES", length=70)
    public String getSotdes() {
        return this.sotdes;
    }

    public void setSotdes(String sotdes) {
        this.sotdes = sotdes;
    }


    @Column(name="SOTTNO", precision=22, scale=0)
    public BigDecimal getSottno() {
        return this.sottno;
    }

    public void setSottno(BigDecimal sottno) {
        this.sottno = sottno;
    }

    @Temporal(TemporalType.DATE)
    @Column(name="SOTDDT ", length=7)
    public Date getSotddt() {
        return this.sotddt;
    }

    public void setSotddt(Date sotddt) {
        this.sotddt = sotddt;
    }

    @Column(name="SOTTIME")
    public Timestamp getSottime() {
        return this.sottime;
    }

    public void setSottime(Timestamp sottime) {
        this.sottime = sottime;
    }
}

错误恰好是 -

SEVERE: ORA-00904: "SINTRANHIS_"."SINID": invalid identifier

Jul 25, 2012 11:25:36 AM com.dchan.codelion.models.Persistent_Model attachDirty
SEVERE: attach failed
org.hibernate.exception.SQLGrammarException: could not retrieve snapshot: [com.dchan.codelion.models.SintranHistory#1]
4

1 回答 1

0

最后发现列名有空格。修复后一切正常

于 2012-07-25T06:04:32.297 回答