Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java EE 综合讨论区 » Hibernate  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 [求助]Error reading resource问题。
David0203





发贴: 7
积分: 0
于 2004-12-27 14:41 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
做了一个hibernate的demo。
在web-INF下classes下建了hibernate.cfg.xml,Address.hbm.xml,Classes.hbm.xml,Students.hbm.xml文件,运行的时候提示
exception

javax.servlet.ServletException: Error reading resource: Students.hbm.xml
  org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
  org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
  org.apache.jsp.index_jsp._jspService(index_jsp.java:69)
  org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

hibernate.cfg.xml:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory >

    <!-- local connection properties -->
    <property name="hibernate.connection.url">jdbc:mysql://localhost/test</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.connection.password"></property>
    <!-- property name="hibernate.connection.pool_size"></property -->

    <!-- dialect for MySQL -->
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

<property name="hibernate.show_sql">true</property>
<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>
<!-- mapping files -->
<mapping resource="Students.hbm.xml"/>
<mapping resource="Classes.hbm.xml"/>
<mapping resource="Courses.hbm.xml"/>
<mapping resource="Address.hbm.xml"/>

</session-factory>
</hibernate-configuration>

Students.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
  "-//Hibernate/Hibernate Mapping DTD//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
  <class name="Hibernate.Students" table="students">
    <id
      column="StudentId"
      name="Id"
      type="string"
    >
      <generator class="assigned" />
    </id>
    <property
      column="ClassesId"
      length="32"
      name="ClassesId"
      not-null="true"
      type="string"
     />
    <property
      column="name"
      length="32"
      name="Name"
      not-null="false"
      type="string"
     />
     <!-- 描述Student和Course多对多的关系-->
<set
name="courses"
table="Student_Course_Link"
lazy="false"
inverse="false"
cascade="all"
sort="unsorted"
>

<key
column="StudentId"
/>

<many-to-many
class="Hibernate.Course"
column="CourseId"
outer-join="auto"
/>
</set>
  <!-- 描述Student和Classes之间多对一的关系-->
<many-to-one
name="classes"
class="Hibernate.Classes"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="ClassesId"
/>

<!-- 描述Student和Address之间一对一的关系-->
<one-to-one
name="address"
class="Hibernate.Address"
cascade="none"
outer-join="auto"
constrained="false"
/>
    
  </class>
</hibernate-mapping>


David0203 edited on 2004-12-27 16:32


话题树型展开
人气 标题 作者 字数 发贴时间
6823 [求助]Error reading resource问题。 David0203 4929 2004-12-27 14:41
6032 Re:[求助]Error reading resource问题。 getup 149 2005-01-18 09:27

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923