使用hibernate出错了请帮我看看

05-03-23 zhangbo198294

运行测试程序的时候抛出了Error reading resource: userInfo/User.hbm.xml的异常:

请帮我看看这个User.hbm.xml里哪写的不对谢谢!

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="userInfo.User" table="usersinfo">

<id name="userName" type="String" unsaved-value="null" >

<column name="username" sql-type="varchar(30)" not-null="true" />

<generator class="Assigned"/>

</id>

<property name="age" type="int">

<column name="age" sql-type="int" not-null="true"/>

</property>

<property name="address" type="string">

<column name="address" sql-type="varchar(60)" />

</property>

</class>

</hibernate-mapping>

对应的JAVA类:

package userInfo;

import java.io.Serializable;

public class User implements Serializable{

private String userName;

private int age;

private String address;

/**

* @return Returns the address.

*/

public String getAddress() {

return address;

}

/**

* @param address The address to set.

*/

public void setAddress(String address) {

this.address = address;

}

/**

* @return Returns the age.

*/

public int getAge() {

return age;

}

/**

* @param age The age to set.

*/

public void setAge(int age) {

this.age = age;

}

/**

* @return Returns the name.

*/

public String getUserName() {

return userName;

}

/**

* @param name The name to set.

*/

public void setUserName(String userName) {

this.userName = userName;

}

}

banq
2005-03-24 10:54

是你的User.hbm.xml中有些语法不对,这是实际中很头痛的问题,Hibernate在简化代码的表面上,实际是将复杂的业务设置转移到XML配置中,这就如同初学者一开始就使用记事本编写计算机语言一样,在无法熟悉语法的情况下,举步维艰啊。

使用一些图形化开发工具提高一下效率。