在使用 Hibernate 进行开发的同时,我遇到了一些问题。我有以下映射文件:
<?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 07-abr-2011 13:29:19 by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="com.cartif.database.Attribute11_CS6" table="Attribute11_CS6">
<id name="iAttrId" column="attributeid" type="java.lang.Integer">
<generator class="sequence">
<param name="sequence">s_attribute_CS6</param>
</generator>
</id>
<property column="name" generated="never" lazy="false" name="sName" type="java.lang.String"/>
<property column="value" generated="never" lazy="false" name="sValue" type="java.lang.String"/>
<property column="timestamp" generated="never" lazy="false" name="tDate" type="java.sql.Timestamp"/>
<property column="deviceId" generated="never" lazy="false" name="iDeviceId" type="java.lang.Integer"/>
<property column="units" generated="never" lazy="false" name="sUnits" type="java.lang.String"/>
<!--<many-to-one cascade="all" name="appField" class="com.cartif.database.ApplicationField" fetch="join">
<column name="applicationfieldid" />
</many-to-one>-->
</class>
</hibernate-mapping>
Java 类是(我不包括 get/set 方法):
public class Attribute11_CS6 implements Serializable{
private static final long serialVersionUID = 1L;
private int iAttrId;
private String sName;
private String sValue;
private String sSensor;
private String sUnits;
private Timestamp tDate;
private int iDeviceId;
当我运行应用程序时,它会抛出一个异常,如下所示:
org.hibernate.InvalidMappingException: Could not parse mapping document from resource resources/Attribute11_CS6.hbm.xml
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:615)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:153)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:535)
at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:616)
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:390)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at com.cartif.monitoring.server.MonitoringServiceImpl.service(MonitoringServiceImpl.java:56)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:322)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:939)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:451)
错误可能是什么?因为我在其他应用程序中使用类似的映射文件而没有问题。我已经检查了几次类,包等。
提前致谢