如题,恳请大家帮个忙
解决方案 »
- struts2_hibernate3.3小例子 不报错 但数据库没反应 小项目在我的资源里面
- java调用.Net Web Service传输数据,传输格式利用XML来传输,但XML不支持Unicode编码的字符串,该怎么办?
- 各位XDJM,那位做过“图形化作业运行监控”
- axis 配置问题,麻烦高手解答一下,非常感谢!!
- 开发设计,接口实现分离
- 如何让Tomcat记录服务器的访问日志呢?
- 求组ing,哪位仁兄帮忙看看啊~!!
- 繁體操作系統下如何寫入一個簡體中文字符串到另一臺簡體系統上的數據庫?
- 求助mybatis中传递参数。。。!
- Tomcat的session的问题
- struts2 如何防止重复提交表单?
- firebug 页面内容正常响应 但报500错误,不显示页面
最好把代码发来看看!!
有两种解决办法:1在hibernate配置文件中修改对应文件的是否延时属性
2用spring filte过滤session
祝你好运!
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration><session-factory>
<property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>
<property name="connection.url">
jdbc:oracle:thin:@test.youth.cn:1521:cycdev
</property>
<property name="connection.username">minzu</property>
<property name="connection.password">cyc123</property>
<property name="connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="current_session_context_class">thread</property>
<property name="show_sql">true</property>
<property name="myeclipse.connection.profile">patriot</property>
<mapping resource="com/cycnet/patriot/pojo/Theme.hbm.xml" />
<mapping resource="com/cycnet/patriot/pojo/Comments.hbm.xml" />
<mapping resource="com/cycnet/patriot/pojo/PresentCatalog.hbm.xml" />
<mapping resource="com/cycnet/patriot/pojo/PresentItem.hbm.xml" />
<mapping resource="com/cycnet/patriot/pojo/Role.hbm.xml" />
<mapping resource="com/cycnet/patriot/pojo/User.hbm.xml" />
<mapping resource="com/cycnet/patriot/pojo/UserMapRole.hbm.xml" />
<mapping
resource="com/cycnet/patriot/pojo/PatriotThemecommentsview.hbm.xml" />
<mapping
resource="com/cycnet/patriot/pojo/RtChinaDivision.hbm.xml" />
<mapping
resource="com/cycnet/patriot/pojo/RtAttractions.hbm.xml" />
<mapping
resource="com/cycnet/patriot/pojo/RtDivisionmapHotpoint.hbm.xml" /></session-factory></hibernate-configuration>
代码都在这,数据库表没做关联
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration><session-factory>
<property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>
<property name="connection.url">
jdbc:oracle:thin:@test.youth.cn:1521:cycdev
</property>
<property name="connection.username">minzu</property>
<property name="connection.password">cyc123</property>
<property name="connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="current_session_context_class">thread</property>
<property name="show_sql">true</property>
<property name="myeclipse.connection.profile">patriot</property>
<mapping resource="com/cycnet/patriot/pojo/Theme.hbm.xml" />
<mapping resource="com/cycnet/patriot/pojo/Comments.hbm.xml" />
<mapping resource="com/cycnet/patriot/pojo/PresentCatalog.hbm.xml" />
<mapping resource="com/cycnet/patriot/pojo/PresentItem.hbm.xml" />
<mapping resource="com/cycnet/patriot/pojo/Role.hbm.xml" />
<mapping resource="com/cycnet/patriot/pojo/User.hbm.xml" />
<mapping resource="com/cycnet/patriot/pojo/UserMapRole.hbm.xml" />
<mapping
resource="com/cycnet/patriot/pojo/PatriotThemecommentsview.hbm.xml" />
<mapping
resource="com/cycnet/patriot/pojo/RtChinaDivision.hbm.xml" />
<mapping
resource="com/cycnet/patriot/pojo/RtAttractions.hbm.xml" />
<mapping
resource="com/cycnet/patriot/pojo/RtDivisionmapHotpoint.hbm.xml" /></session-factory></hibernate-configuration>
这个文件的代码都在这,数据库表没做关联
这个错误一般是配置问题,我也遇到这个问题,后来解决了。需要关注的问题:
1.是不是用的mysql数据库?
2.有没有用连接池?
3.出现这个问题一般是事物的使用不当,或者是配置,或者是代码有问题。
4.建议把配置文件都写成这种形式:<property name="connection.username" value="minzu" />
貌似是懒加载导致到前台页面获取被懒加载的数据会取不到,并报错为seesion is closed.用OpenSessionInView可以解决这个问题,我估计楼主你是遇到这个问题了。
看看这个例子
http://wb8804220725.javaeye.com/blog/457049