2012-07-25 28 views
0

當我執行一個查詢保存在Hibernate中的對象 - 生成的查詢是錯誤的 - 下面是Hibernate生成的查詢 -無效的ID - 僅表名的一部分採取休眠

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", [email protected](name="SOTTYP", nullable=false, length=12)), 
     @AttributeOverride(name="sotid", [email protected](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] 

回答

0

最後發現, re是列名中的空格。修復後,一切正常工作