2013-07-23 85 views
0

我正在創建一個基於Web的系統,它利用Hibernate框架。我用netbeans工具創建了休眠配置& pojo類。它可以很好地工作,但是當我嘗試創建碧玉報告時會出現問題。Jasper與Hibernate的報告,複合鍵

我有一個名爲「external_shipping」的表,它有一個複合鍵。 XML映射文件如下

<?xml version="1.0"?> 
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> 
<!-- Generated Jul 23, 2013 1:34:21 PM by Hibernate Tools 3.2.1.GA --> 
<hibernate-mapping> 
    <class name="pojo.ExternalShipping" table="external_shipping" catalog="bit_final_year_project"> 
     <composite-id name="id" class="pojo.ExternalShippingId"> 
      <key-property name="agentId" type="int"> 
       <column name="agent_id" /> 
      </key-property> 
      <key-property name="buyerId" type="int"> 
       <column name="buyer_id" /> 
      </key-property> 
      <key-property name="shippingId" type="int"> 
       <column name="shipping_id" /> 
      </key-property> 
     </composite-id> 
     <many-to-one name="externalByBuyerId" class="pojo.External" update="false" insert="false" fetch="select"> 
      <column name="buyer_id" not-null="true" /> 
     </many-to-one> 
     <many-to-one name="externalByAgentId" class="pojo.External" update="false" insert="false" fetch="select"> 
      <column name="agent_id" not-null="true" /> 
     </many-to-one> 
     <many-to-one name="externalByConsigneeId" class="pojo.External" fetch="select"> 
      <column name="consignee_id" /> 
     </many-to-one> 
     <many-to-one name="shipping" class="pojo.Shipping" update="false" insert="false" fetch="select"> 
      <column name="shipping_id" not-null="true" /> 
     </many-to-one> 
    </class> 
</hibernate-mapping> 

Netbeans的自動創建的類爲「ExternalShippingId」級。就是這個。

package pojo; 
// Generated Jul 23, 2013 1:34:17 PM by Hibernate Tools 3.2.1.GA 


import javax.persistence.Column; 
import javax.persistence.Embeddable; 

/** 
* ExternalShippingId generated by hbm2java 
*/ 
@Embeddable 
public class ExternalShippingId implements java.io.Serializable { 


    private int agentId; 
    private int buyerId; 
    private int shippingId; 

    public ExternalShippingId() { 
    } 

    public ExternalShippingId(int agentId, int buyerId, int shippingId) { 
     this.agentId = agentId; 
     this.buyerId = buyerId; 
     this.shippingId = shippingId; 
    } 


    @Column(name="agent_id", nullable=false) 
    public int getAgentId() { 
     return this.agentId; 
    } 

    public void setAgentId(int agentId) { 
     this.agentId = agentId; 
    } 

    @Column(name="buyer_id", nullable=false) 
    public int getBuyerId() { 
     return this.buyerId; 
    } 

    public void setBuyerId(int buyerId) { 
     this.buyerId = buyerId; 
    } 

    @Column(name="shipping_id", nullable=false) 
    public int getShippingId() { 
     return this.shippingId; 
    } 

    public void setShippingId(int shippingId) { 
     this.shippingId = shippingId; 
    } 


    public boolean equals(Object other) { 
     if ((this == other)) return true; 
     if ((other == null)) return false; 
     if (!(other instanceof ExternalShippingId)) return false; 
     ExternalShippingId castOther = (ExternalShippingId) other; 

     return (this.getAgentId()==castOther.getAgentId()) 
&& (this.getBuyerId()==castOther.getBuyerId()) 
&& (this.getShippingId()==castOther.getShippingId()); 
    } 

    public int hashCode() { 
     int result = 17; 

     result = 37 * result + this.getAgentId(); 
     result = 37 * result + this.getBuyerId(); 
     result = 37 * result + this.getShippingId(); 
     return result; 
    } 


} 

所以,當我試圖在碧玉報告(netbean插件)的連接,它給了我錯誤的

組件類未找到:ExternalShippingId

我添加類路徑爲

C:\ Users \ dell \ Documents \ NetBeansProjects \ DocumentManagementProject \ src \ jav a

但它給出了同樣的錯誤。任何想法呢?

+0

Netbeans沒有爲ExternalShippingId創建hbm.xml文件 – Sumer

回答

0

類路徑必須引用包含.class文件而不是.java源文件的文件夾。