2012-02-15 71 views
0

我將我的代碼中的映射從xml資源切換到註釋並得到該異常。我沒有看到錯誤。我想你可以從我的代碼弄明白:org.hibernate.InvalidMappingException:無法從資源解析映射文檔

的hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> 
<hibernate-configuration> 
    <session-factory> 
    <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property> 
    <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property> 
    <property name="hibernate.connection.url">####</property> 
    <property name="hibernate.connection.username">##</property> 
    <property name="hibernate.connection.password">###</property> 
    <property name="hibernate.current_session_context_class">thread</property> 
    <property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property> 
    <property name="hibernate.show_sql">true</property> 
    <mapping class="max.Trade" file="" jar="" package="max" resource=""/> 
    </session-factory> 
</hibernate-configuration> 

Trade.java

@Entity 
@Table(name="TRADES", schema="PGT") 
public class Trade implements java.io.Serializable 
{ 
    private long murexId; 
    private String type; 
    private String portfolio; 

    public Trade() { 
    } 

    public Trade(long murexId) { 
     this.murexId = murexId; 
    } 

    public Trade(long murexId, String type, String portfolio) { 
     this.murexId = murexId; 
     this.type = type; 
     this.portfolio = portfolio; } 

    @Id 
    @Column(name="MUREX_ID", unique=true, nullable=false, precision=10, scale=0) 
    public long getMurexId() { 
     return this.murexId; 
    } 

    public void setMurexId(long murexId) { 
     this.murexId = murexId; 
    } 

    @Column(name="TYPE", length=32) 
    public String getType() { 
     return this.type; 
    } 

    public void setType(String type) { 
     this.type = type; 
    } 

    @Column(name="PORTFOLIO", length=32) 
    public String getPortfolio() { 
     return this.portfolio; 
    } 

    public void setPortfolio(String portfolio) { 
     this.portfolio = portfolio; 
    } 

} 

我會很感激的任何幫助。

謝謝!

回答

0

替換映射定義(標記)作爲

<mapping class="max.Trade"/> 
相關問題