hibernate oracle 流关闭

y591174893 2012-06-03 06:33:53
跪求请各位大侠帮忙:
异常信息:
org.hibernate.exception.GenericJDBCException: could not initialize a collection: [com.bbs.model.Member.sendInvitations#2]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.loadCollection(Loader.java:2173)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:62)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:627)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:83)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1863)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:369)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:111)
at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:186)
at com.bbs.model.TestMemberTable.testSelectInsertInvitation(TestMemberTable.java:193)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.sql.SQLException: 流已被关闭
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.driver.LongAccessor.getBytes(LongAccessor.java:151)
at oracle.jdbc.driver.LongAccessor.getString(LongAccessor.java:193)
at oracle.jdbc.driver.T4CLongAccessor.getString(T4CLongAccessor.java:422)
at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:397)
at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1515)
at com.mchange.v2.c3p0.impl.NewProxyResultSet.getString(NewProxyResultSet.java:3342)
at org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$2.doExtract(VarcharTypeDescriptor.java:61)
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:249)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:229)
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:330)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2265)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1527)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1455)
at org.hibernate.loader.Loader.getRow(Loader.java:1355)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:611)
at org.hibernate.loader.Loader.doQuery(Loader.java:829)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.loadCollection(Loader.java:2166)
... 27 more

测试代码:
public void testSelectInsertInvitation(){
Session session = HibernateSessionFactory.getSession();
Transaction transaction = session.beginTransaction();
Member member = (Member)session.get(Member.class, 2);
Set<Invitation> invitations = member.getSendInvitations();
for ( Invitation invitation : invitations) {
System.out.println(invitation.getContent());
System.out.println("帖子内容是: "+invitation.getContent()+" 时间是 : "+invitation.getInvitationDate());
}
transaction.commit();
HibernateSessionFactory.closeSession();
}
配置文件1:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.bbs.model">
<class name="Invitation" table="Invitation">
<id name="id" column="Invitation_id">
<generator class="hilo"></generator>
</id>
<property name="isOver"></property>
<property name="title"></property>
<property name="InvitationDate"></property>
<property name="content" length="10000"></property>
<!-- 映射帖子 的版块 -->
<property name="sectionId"></property>
<!-- 有链接表双向一对多对应回帖 -->
<set name="backInvitation" table="Invitation_BackInvitation" inverse="true">
<key column="Invitation_id"></key>
<many-to-many column="BackInvitation_id" class="BackInvitation"
unique="true" order-by="backInvitationDate asc"></many-to-many>
</set>
<!-- 双向一对多 -->

<!-- 映射发帖和用户的关系 -->
<many-to-one name="sendInvitationMember" class="Member" column="Member_id"></many-to-one>
<!-- 继承 -->
<union-subclass name="UpFile" table="UpFile">
<property name="filePath"></property>
<property name="FileName"></property>
<property name="needGrate"></property>

</union-subclass>
</class>

</hibernate-mapping>
配置文件2:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.bbs.model">
<class name="Member" table="member">
<id name="id" column="Member_id">
<generator class="hilo"></generator>
</id>
<property name="userName" unique="true"></property>
<property name="passWord"></property>
<property name="gender"></property>
<property name="birthday"></property>
<property name="email"></property>
<property name="grade"></property>
<property name="image"></property>
<property name="registerDate"></property>
<property name="userType"></property>
<!-- 映射会员参加的帖子 -->
<set name="participationInvitations" table="member_joinInvitations" inverse="true" lazy="true">
<key column="Member_id"></key>
<many-to-many class="BackInvitation" column="BackInvitation_id"
unique="true" order-by="backInvitationDate asc"/>
</set>
<!-- 映射会员的friend表 -->
<set name="friends" table="member_friends" inverse="true" lazy="true">
<key column="Member_id"></key>
<many-to-many class="Friend" column="Friend_id" unique="true" >
</many-to-many>
</set>
<!-- 有链接表的一对多, 映射 留言表 -->
<set name="leaveWords" table="member_leavewords" inverse="true" lazy="true">
<key column="Member_id"></key>
<many-to-many class="LeaveWords" column="LeaveWords_id"
unique="true" order-by="LeaveWordDate asc">
</many-to-many>
</set>
<!-- 映射用户发起的帖子 应该映射成为有序的 -->
<set name="sendInvitations" inverse="true" lazy="true">
<key column="Member_id"></key>
<one-to-many class="Invitation"/>
</set>
<union-subclass name="Moderator" table="Moderator">
<one-to-one name="section" property-ref="sectionOfModerator"></one-to-one>
<property name="beginDate"></property>
<property name="realName"></property>
<property name="cellphone"></property>
<property name="phone"></property>
<union-subclass name="Manager" table="Manager">
<property name="address"></property>
<property name="educationBackground"></property>
</union-subclass>
</union-subclass>
</class>


</hibernate-mapping>
把配置文件1中的红色代码去可以成功运行,但是加上之后就不行了,请大侠帮帮忙吧,分不够的可以再加!
...全文
341 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧