我正在创建一个利用 Hibernate 框架的基于 Web 的系统。我已经使用 netbeans 工具创建了休眠配置和 pojo 类。它工作得很好,但是当我尝试创建碧玉报告时会出现问题。
我有一个名为“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;
}
}
因此,当我尝试在 jasper 报告(netbean 插件)中建立连接时,它给了我错误
未找到组件类:ExternalShippingId
我已将类路径添加为
C:\Users\dell\Documents\NetBeansProjects\DocumentManagementProject\src\java
但它给出了同样的错误。有什么想法吗????