谁会hibernate 呢 ( 积分: 100 )

  • 主题发起人 主题发起人 goddy
  • 开始时间 开始时间
G

goddy

Unregistered / Unconfirmed
GUEST, unregistred user!
<class name=&quot;com.dao.login.Login&quot;
table=&quot;TUser&quot;>
<ID name=&quot;UserNO&quot;
column=&quot;UserNO&quot;
type=&quot;String&quot;
unsaved-value=&quot;any&quot;>
<generator class=&quot;assigned&quot;
/>
</ID>
<property name=&quot;UserName&quot;
type=&quot;string&quot;
>
<column name=&quot;UserName&quot;
length=&quot;50&quot;
/>
</property>
<property name=&quot;DeptID&quot;
column=&quot;DeptID&quot;
type=&quot;int&quot;
/>
<property name=&quot;Email&quot;
type=&quot;string&quot;
>
<column name=&quot;Email&quot;
length=&quot;100&quot;
/>
</property>
<property name=&quot;LoginDate&quot;
column=&quot;LoginDate&quot;
type=&quot;timestamp&quot;
>
</property>
<property name=&quot;LoginCount&quot;
column=&quot;LoginCount&quot;
type=&quot;int&quot;
/>
</class>
出错
哪里有问题呢
2005-8-13 21:09:48 net.sf.hibernate.cfg.Configuration addClass
信息: Mapping resource: com/dao/login/Login.hbm.xml
2005-8-13 21:09:48 net.sf.hibernate.util.XMLHelper$ErrorLogger error
严重: Error parsing XML: XML InputStream(8) Element type &quot;ID&quot;
must be declared.
2005-8-13 21:09:48 net.sf.hibernate.util.XMLHelper$ErrorLogger error
严重: Error parsing XML: XML InputStream(21) The content of element type &quot;class&quot;
must match &quot;(meta*,(cache|jcs-cache)?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,(subclass*|joined-subclass*))&quot;.
net.sf.hibernate.MappingException: Error reading resource: com/dao/login/Login.hbm.xml
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:357)
at com.web.login.LoginAction.execute(LoginAction.java:26)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:287)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:354)
... 31 more
Caused by: org.xml.sax.SAXParseException: Element type &quot;ID&quot;
must be declared.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:286)
... 32 more
 
<class name=&quot;com.dao.login.Login&quot;
table=&quot;TUser&quot;>
<ID name=&quot;UserNO&quot;
column=&quot;UserNO&quot;
type=&quot;String&quot;
unsaved-value=&quot;any&quot;>
<generator class=&quot;assigned&quot;
/>
</ID>
<property name=&quot;UserName&quot;
type=&quot;string&quot;
>
<column name=&quot;UserName&quot;
length=&quot;50&quot;
/>
</property>
<property name=&quot;DeptID&quot;
column=&quot;DeptID&quot;
type=&quot;int&quot;
/>
<property name=&quot;Email&quot;
type=&quot;string&quot;
>
<column name=&quot;Email&quot;
length=&quot;100&quot;
/>
</property>
<property name=&quot;LoginDate&quot;
column=&quot;LoginDate&quot;
type=&quot;timestamp&quot;
>
</property>
<property name=&quot;LoginCount&quot;
column=&quot;LoginCount&quot;
type=&quot;int&quot;
/>
</class>
出错
哪里有问题呢
2005-8-13 21:09:48 net.sf.hibernate.cfg.Configuration addClass
信息: Mapping resource: com/dao/login/Login.hbm.xml
2005-8-13 21:09:48 net.sf.hibernate.util.XMLHelper$ErrorLogger error
严重: Error parsing XML: XML InputStream(8) Element type &quot;ID&quot;
must be declared.
2005-8-13 21:09:48 net.sf.hibernate.util.XMLHelper$ErrorLogger error
严重: Error parsing XML: XML InputStream(21) The content of element type &quot;class&quot;
must match &quot;(meta*,(cache|jcs-cache)?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,(subclass*|joined-subclass*))&quot;.
net.sf.hibernate.MappingException: Error reading resource: com/dao/login/Login.hbm.xml
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:357)
at com.web.login.LoginAction.execute(LoginAction.java:26)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:287)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:354)
... 31 more
Caused by: org.xml.sax.SAXParseException: Element type &quot;ID&quot;
must be declared.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:286)
... 32 more
 
<ID name=&quot;UserNO&quot;
column=&quot;UserNO&quot;
type=&quot;String&quot;
unsaved-value=&quot;any&quot;>
<generator class=&quot;assigned&quot;
/>
</ID>
请注意小写!
<id>
</id>
 
Hibernate配置文件区分大小写的。简易用工具,比如Middlegen什么的。
 
Mapping resource: com/dao/login/Login.hbm.xml
你没有生成或添加Login.hbm文件
<mapping resource=&quot;Login.hbm&quot;
/>
 
多人接受答案了。
 

Similar threads

后退
顶部