运行测试程序时有如下信息
INFO net.sf.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml INFO net.sf.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
这说明configuration.configure().buildSessionFactory();能正确执行了吧
映射文件也能够读取
可为什么还出现Not binding factory to JNDI, no JNDI name configured 的错误???
还有 null<-org.dom4j.tree.DefaultAttribute@18f51f [Attribute: name resource value "Customer.hbm.xml"]
测试过程中发现 session能生成 可session.beginTransaction();不能执行
为什么啊??
找了一天的时间了都没有找到原因
INFO net.sf.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml INFO net.sf.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
这说明configuration.configure().buildSessionFactory();能正确执行了吧
映射文件也能够读取
可为什么还出现Not binding factory to JNDI, no JNDI name configured 的错误???
还有 null<-org.dom4j.tree.DefaultAttribute@18f51f [Attribute: name resource value "Customer.hbm.xml"]
测试过程中发现 session能生成 可session.beginTransaction();不能执行
为什么啊??
找了一天的时间了都没有找到原因
解决方案 »
- Spring的HibernateTemplate在web容器中运行报错,在main函数中测试却运行正常,这是为什么?
- 一个比较费解的编码问题!其实大家应该明白地,可能我太小白。
- 就没一个懂得么?急急急
- el的乱码问题
- 初学者遇Hibernate问题,请大家指点!!!
- [求助]哪位大侠有SVF(Super Visual Formade Java PRODUCTS)安装包啊?
- 向一个Vector里添加一个正数,提示出错?
- 中文问题?我的机器装了JBUILDER9.0,JSP连的是SQLSERVER2000,从数据库读出来的中文要转码才能正常显示,但在别的机器上不用转码就是好的(如
- 急!中文显示问题
- 启动spring boot 报错
- visual web jsf实现的Ajax问题(基础)
- 如何将 1,2,3,4 转化成大多的整形 ?
你有这个映射文件吗?
如果没有就在hbm.cfg.xml里面去掉.IT资源网,Java/J2EE技术教程
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"><hibernate-mapping>
<class name="springpro.Customer" table="CUSTOMERS">
<id name="id" column="ID" type="long">
<generator class="increment"/>
</id>
<property name="name" column="NAME" type="string" not-null="true" />
<property name="password" column="PASSWORD" type="string" not-null="true"/>
<property name="sex" column="SEX" type="character"/>
<property name="email" column="EMAIL" type="string" not-null="true" />
<property name="telePhone" column="TELEPHONE" type="string" />
<property name="fixPhone" column="FIXPHONE" type="string" />
<property name="address" column="ADDRESS" type="string" />
<property name="registeredTime" column="REGISTERED_TIME" type="timestamp"/>
</class></hibernate-mapping>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> <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property> <!-- Mapping files -->
<mapping resource="Customer.hbm.xml"/> </session-factory></hibernate-configuration>
<mapping resource="包名/子包名/Customer.hbm.xml"/>
现在改用spring的HibernateDaoSupport了