2011-01-07 194 views
1

我有3類,其中休眠級聯在繼承

用戶< ------ PersonalUser < ------管理員

示例用戶映射文件:

<class name="com.BiddingSystem.Models.Users" table="USERS"> 

</class> 

樣品個人用戶映射文件

<joined-subclass name="com.BiddingSystem.Models.PersonalUser" extends="com.BiddingSystem.Models.Users" table="PERSONALUSER" lazy="false" cascade="all"> 

</joined-subclass> 

樣本管理員用戶映射文件:

<joined-subclass cascade="all" name="com.BiddingSystem.Models.Administrator" extends="com.BiddingSystem.Models.PersonalUser" table="ADMINISTRATOR" lazy="false"> 

</joined-subclass> 

,但是當我試圖刪除管理員,我收到以下錯誤:

堆棧跟蹤:

org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/BiddingSystem/Models/Administrator.hbm.xml 
    at org.hibernate.cfg.Configuration.addResource(Configuration.java:671) 
    at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1679) 
    at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1647) 
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1626) 
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1600) 
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1520) 
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1506) 
    at com.BiddingSystem.server.ServiceImpl.<init>(ServiceImpl.java:63) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
    at java.lang.Class.newInstance0(Class.java:355) 
    at java.lang.Class.newInstance(Class.java:308) 
    at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153) 
    at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339) 
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:463) 
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362) 
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) 
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) 
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729) 
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405) 
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) 
    at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49) 
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) 
    at org.mortbay.jetty.Server.handle(Server.java:324) 
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) 
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843) 
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647) 
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) 
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) 
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395) 
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488) 
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping 
    at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:604) 
    at org.hibernate.cfg.Configuration.addResource(Configuration.java:668) 
    ... 32 more 
Caused by: org.xml.sax.SAXParseException: Attribute "cascade" must be declared for element type "joined-subclass". 
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) 
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131) 
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384) 
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318) 
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(XMLDTDValidator.java:1275) 
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1940) 
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:764) 
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648) 
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511) 
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808) 
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) 
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119) 
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) 
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522) 
    at org.dom4j.io.SAXReader.read(SAXReader.java:465) 
    at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:601) 
    ... 33 more 
+0

你是否確定刪除管理員時發生此錯誤? - 當你啓動應用程序時,我會期待一個設置錯誤! – Ralph 2011-01-07 12:44:47

回答