org.hibernate.InvalidMappingException:无法解析资源中的映射文档

时间:2012-02-15 04:45:14

标签: java hibernate

我将代码中的映射从xml资源切换到注释,并获得了该异常。我没有看到错误。我想你可以从我的代码中找到它:

的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;
    }

}

我真的很感激任何帮助。

谢谢!

1 个答案:

答案 0 :(得分:0)

将映射定义(标记)替换为

<mapping class="max.Trade"/>