Define the class as:
public class aa
{
private int id;
private String name;
private int sort;
public aa ()
{
}
public void setId (int Id)
{
this.id = Id;
}
public int getId ()
{
return this.id;
}
public void setSort (int Sort)
{
this.sort = Sort;
}
public int getSort ()
{
return this.sort;
}
public void setName (String Name)
{
this.name = Name;
}
public String getName ()
{
return this.name;
}
}
The xml file is configured as:
<? xml version = "1.0"?>
<! DOCTYPE hibernate-mapping PUBLIC
"-// Hibernate / Hibernate Mapping DTD 3.0 // EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package = "......">
<class name = "aa" table = "t_aa">
<id name = "Id">
<generator class = "native" />
</ id>
<property name = "Name" />
<property name = "Sort" />
</ class>
</ hibernate-mapping>
The trace exceptions in the debug state are:
"Could not prase mapping document from resource aa.hbm.xml"
"class aa not found while looking for property: Id"
The end error page is:
HTTP Status 500-type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service (JspServletWrapper.java:370)
org.apache.jasper.servlet.JspServlet.serviceJspFile (JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service (JspServlet.java:241)
javax.servlet.http.HttpServlet.service (HttpServlet.java:802)
root cause java.lang.NullPointerException
com.sudytech.hibernate.HibernateFactory.currentSession (HibernateFactory.java:49)
org.apache.jsp.test_jsp._jspService (org.apache.jsp.test_jsp: 60)
org.apache.jasper.runtime.HttpJspBase.service (HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service (HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service (JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile (JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service (JspServlet.java:241)
javax.servlet.http.HttpServlet.service (HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat / 5.5.9 logs.Apache Tomcat / 5.5.9
"Could not prase mapping document from resource aa.hbm.xml"
"class aa not found while looking for property: Id"
<id name = "Id">
<generator class = "native" />
</ id>
As LS said, if it doesn't work, change it to
<id name = "Id">
</ id>
Originally, your id type is incorrect. When writing Pojo classes, you should write your id type as Long. This is the specification for writing Pojo classes.
Also, the attributes in the mapping file must be the same as those in pojo