在hibernate中找不到组件类
每当我尝试将ireport与netbeans中的hibernate连接时,就会出现错误“component class not found:Sustainability.ProductionSavingId”。当我运行该程序时,它不会显示任何错误,但当我尝试使用hibernate将ireport连接到数据库时,它会抛出错误。我已经添加了所需的类路径和jar文件在hibernate中找不到组件类,hibernate,netbeans,jasper-reports,ireport,Hibernate,Netbeans,Jasper Reports,Ireport,每当我尝试将ireport与netbeans中的hibernate连接时,就会出现错误“component class not found:Sustainability.ProductionSavingId”。当我运行该程序时,它不会显示任何错误,但当我尝试使用hibernate将ireport连接到数据库时,它会抛出错误。我已经添加了所需的类路径和jar文件 <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-
<?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 Feb 1, 2013 7:21:28 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="Sustainability.Productionsaving" table="productionsaving" catalog="gdp">
<composite-id name="id" class="Sustainability.ProductionsavingId">
<key-property name="categoryName" type="string">
<column name="CategoryName" length="25" />
</key-property>
<key-property name="date" type="timestamp">
<column name="Date" length="19" />
</key-property>
</composite-id>
<many-to-one name="users" class="Sustainability.Users" fetch="select">
<column name="Username" length="20" />
</many-to-one>
<many-to-one name="category" class="Sustainability.Category" update="false" insert="false" fetch="select">
<column name="CategoryName" length="25" not-null="true" />
</many-to-one>
<property name="savingAmount" type="java.lang.Double">
<column name="SavingAmount" precision="22" scale="0" />
</property>
<property name="quantity" type="java.lang.Double">
<column name="Quantity" precision="22" scale="0" />
</property>
<property name="unit" type="string">
<column name="Unit" length="5" />
</property>
</class>
</hibernate-mapping>
<?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 Feb 1, 2013 7:21:28 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="Sustainability.Productionsaving" table="productionsaving" catalog="gdp">
<composite-id name="id" class="Sustainability.ProductionsavingId">
<key-property name="categoryName" type="string">
<column name="CategoryName" length="25" />
</key-property>
<key-property name="date" type="timestamp">
<column name="Date" length="19" />
</key-property>
</composite-id>
<many-to-one name="users" class="Sustainability.Users" fetch="select">
<column name="Username" length="20" />
</many-to-one>
<many-to-one name="category" class="Sustainability.Category" update="false" insert="false" fetch="select">
<column name="CategoryName" length="25" not-null="true" />
</many-to-one>
<property name="savingAmount" type="java.lang.Double">
<column name="SavingAmount" precision="22" scale="0" />
</property>
<property name="quantity" type="java.lang.Double">
<column name="Quantity" precision="22" scale="0" />
</property>
<property name="unit" type="string">
<column name="Unit" length="5" />
</property>
</class>
</hibernate-mapping>
/**
* Productionsaving generated by hbm2java
*/
public class Productionsaving implements java.io.Serializable {
private ProductionsavingId id;
private Users users;
private Category category;
private Double savingAmount;
private Double quantity;
private String unit;
public Productionsaving() {
}
public Productionsaving(ProductionsavingId id, Category category) {
this.id = id;
this.category = category;
}
public Productionsaving(ProductionsavingId id, Users users, Category category, Double savingAmount, Double quantity, String unit) {
this.id = id;
this.users = users;
this.category = category;
this.savingAmount = savingAmount;
this.quantity = quantity;
this.unit = unit;
}
public ProductionsavingId getId() {
return this.id;
}
public void setId(ProductionsavingId id) {
this.id = id;
}
public Users getUsers() {
return this.users;
}
public void setUsers(Users users) {
this.users = users;
}
public Category getCategory() {
return this.category;
}
public void setCategory(Category category) {
this.category = category;
}
public Double getSavingAmount() {
return this.savingAmount;
}
public void setSavingAmount(Double savingAmount) {
this.savingAmount = savingAmount;
}
public Double getQuantity() {
return this.quantity;
}
public void setQuantity(Double quantity) {
this.quantity = quantity;
}
public String getUnit() {
return this.unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
}
import java.util.Date;
/**
* ProductionsavingId generated by hbm2java
*/
public class ProductionsavingId implements java.io.Serializable {
private String categoryName;
private Date date;
public ProductionsavingId() {
}
public ProductionsavingId(String categoryName, Date date) {
this.categoryName = categoryName;
this.date = date;
}
public String getCategoryName() {
return this.categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public Date getDate() {
return this.date;
}
public void setDate(Date date) {
this.date = date;
}
public boolean equals(Object other) {
if ( (this == other ) ) return true;
if ( (other == null ) ) return false;
if ( !(other instanceof ProductionsavingId) ) return false;
ProductionsavingId castOther = ( ProductionsavingId ) other;
return ( (this.getCategoryName()==castOther.getCategoryName()) || ( this.getCategoryName()!=null && castOther.getCategoryName()!=null && this.getCategoryName().equals(castOther.getCategoryName()) ) )
&& ( (this.getDate()==castOther.getDate()) || ( this.getDate()!=null && castOther.getDate()!=null && this.getDate().equals(castOther.getDate()) ) );
}
public int hashCode() {
int result = 17;
result = 37 * result + ( getCategoryName() == null ? 0 : this.getCategoryName().hashCode() );
result = 37 * result + ( getDate() == null ? 0 : this.getDate().hashCode() );
return result;
}
}
/**
*hbm2java生成的产品节省
*/
公共类ProductionSave实现java.io.Serializable{
私人产品保存id;
私人用户;
私人类别;
私人双储蓄山;
私人双倍数量;
专用字符串单元;
公共产品储蓄{
}
公共产品存储(ProductionsavingId,类别){
this.id=id;
this.category=类别;
}
公共产品存储(产品存储id、用户、类别、双存储量、双数量、字符串单位){
this.id=id;
this.users=用户;
this.category=类别;
this.savingAmount=savingAmount;
这个。数量=数量;
这个。单位=单位;
}
公共产品savingid getId(){
返回此.id;
}
public void setId(ProductionsavingId id){
this.id=id;
}
公共用户getUsers(){
将此文件返回给用户;
}
公共void setUsers(用户){
this.users=用户;
}
公共类别getCategory(){
返回此.category;
}
公共无效集合类别(类别){
this.category=类别;
}
公共双getSavingAmount(){
归还这个。萨文加蒙特;
}
公共空间设置安全支座(双安全支座){
this.savingAmount=savingAmount;
}
公共双getQuantity(){
退回这个数量;
}
公共无效设置数量(双倍数量){
这个。数量=数量;
}
公共字符串getUnit(){
返回此.unit;
}
公共无效设置单位(字符串单位){
这个。单位=单位;
}
}
导入java.util.Date;
/**
*hbm2java生成的ProductionsavingId
*/
公共类ProductionsavingId实现java.io.Serializable{
私有字符串categoryName;
私人日期;
公共产品储蓄{
}
public ProductionsavingId(字符串categoryName,Date){
this.categoryName=categoryName;
this.date=日期;
}
公共字符串getCategoryName(){
返回this.categoryName;
}
公共无效setCategoryName(字符串categoryName){
this.categoryName=categoryName;
}
公共日期getDate(){
返回此日期;
}
公共作废设置日期(日期){
this.date=日期;
}
公共布尔等于(对象其他){
if((this==other))返回true;
if((other==null))返回false;
如果(!(ProductionsavingId的其他实例))返回false;
ProductionsavingId castOther=(ProductionsavingId)其他;
return((this.getCategoryName()==castOther.getCategoryName())| |(this.getCategoryName()!=null&&castOther.getCategoryName()!=null&&this.getCategoryName().equals(castOther.getCategoryName()))
&&((this.getDate()==castOther.getDate())| |(this.getDate()!=null&&castOther.getDate()!=null&&this.getDate().equals(castOther.getDate()));
}
公共int hashCode(){
int结果=17;
result=37*result+(getCategoryName()==null?0:this.getCategoryName().hashCode());
result=37*result+(getDate()==null?0:this.getDate().hashCode());
返回结果;
}
}
该错误表示您正在引用类路径中不存在的类。确保使用正确的包名和类名引用该类。我觉得你的包裹名称不标准。应该是这样的
com.mycompany.whatever.Sustainability
所以一定不要错过那个。我还注意到,在您粘贴的错误中,ProductionSavingId
的大小写与您显示的hbm中的大小写不同。也许这是一种区分大小写的不匹配