Hibernate,将.hbm.xml文件添加到cfg.xml文件中

发布于 2024-11-16 11:04:05 字数 2526 浏览 3 评论 0原文

我需要一些信息

什么是 hbm.xml 文件???我只知道 *.hbm 文件

以及如何将 .hbm.xml 文件添加到 cfg.xml 文件???

我想知道,因为当我尝试运行 jsp 时出现错误,他们说您必须将 .hbm.xml 文件添加到 cfg.xml 文件!

这是错误:

exception 

org.apache.jasper.JasperException: javax.servlet.ServletException: net.sf.hibernate.MappingException: No persister for: MyDB.student org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:531) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

导致

javax.servlet.ServletException: net.sf.hibernate.MappingException: No persister for: MyDB.student org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:901) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:830) org.apache.jsp.JSP.index_jsp._jspService(index_jsp.java:103) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

导致 mère

net.sf.hibernate.MappingException: No persister for: MyDB.student net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:347) net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2690) net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2697) net.sf.hibernate.impl.SessionImpl.saveWithGenerateIdentifier(SessionImpl.java:763) net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738) org.apache.jsp.JSP.index_jsp._jspService(index_jsp.java:75) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

i need some information

what is a hbm.xml file ??? i know just *.hbm files

and how to add the .hbm.xml file to the cfg.xml file ???

i want to know that cuz i get an error when im trying to run my jsp and they said you have to add the .hbm.xml file to the cfg.xml file !!

this is the error :

exception 

org.apache.jasper.JasperException: javax.servlet.ServletException: net.sf.hibernate.MappingException: No persister for: MyDB.student
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:531)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

cause mère

javax.servlet.ServletException: net.sf.hibernate.MappingException: No persister for: MyDB.student
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:901)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:830)
org.apache.jsp.JSP.index_jsp._jspService(index_jsp.java:103)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

cause mère

net.sf.hibernate.MappingException: No persister for: MyDB.student
net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:347)
net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2690)
net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2697)
net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:763)
net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
org.apache.jsp.JSP.index_jsp._jspService(index_jsp.java:75)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

抹茶夏天i‖ 2024-11-23 11:04:05
  1. hbm 文件通常是 XML,并且通常具有扩展名 .hbm.xml 。如果您仅将它们命名为 .hbm,则违反了约定。

  2. 您不必从 hibernate.cfg.xml 映射它们 - 您可以通过编程或通过 Spring 来完成。

  3. 如果您愿意,只需添加与此类似的内容即可

     <映射资源=“org/hibernate/auction/Item.hbm.xml”/>
        <映射资源=“org/hibernate/auction/Bid.hbm.xml”/>
    
  1. hbm files are normally XML and normally have the extension .hbm.xml . If you named them just .hbm, you broke convention.

  2. You don't have to map them all from hibernate.cfg.xml - you can do it programmatically or via Spring.

  3. If you want to though, you just add them similar to this

        <mapping resource="org/hibernate/auction/Item.hbm.xml"/>
        <mapping resource="org/hibernate/auction/Bid.hbm.xml"/>
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文