求助,关于RMI远程调用hibernate服务出现问题
大概是一个RMI远程调用Hinerbate 出现session 无法链接的问题。
有Role Function两个类,单向多对多关联。中间表permission
Role类
public class BaseGrouptbl implements java.io.Serializable {
private String groupid;
。。。
private Set functions = new HashSet();
下面是Role 的配置文件
<hibernate-mapping>
<class name="model.BaseGrouptbl" table="BASE_GROUPTBL">
<id name="groupid" type="string">
<column name="GROUPID" length="10" />
<generator class="assigned" />
</id>
<set name="functions" table="base_permissiontbl" lazy="false" fetch="join" cascade="save-update">
<key column="groupid"></key>
<many-to-many class="model.BaseFunctiontbl" column="funcid"></many-to-many>
</set>
</class>
</hibernate-mapping>
然后问题是这样:
当我通过客户端调用 服务端的查询 类Role的方法(方法采用HQL语句查询)时,会出现那种像延时加载而session已关闭时的异常。
可是我确实把lazy设为false了啊。
已确定的:
1、RMI配置无问题,其他方法都可以调用
2、看一下当作服务端的项目的日志,Role 的Function Set 确实有取出来
3、对于Role对象,采用SQL语句查询无问题,可是我还要Function类啊
4、增加没问题,中间表也能加进去
5、当不用远程调用时,方法没问题
最后附上异常:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throw
LazyInitializationException(AbstractPersistentCollection.java:383)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:375)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:368)
at org.hibernate.collection.PersistentSet.add(PersistentSet.java:212)
at com.caucho.hessian.io.CollectionDeserializer.readList(CollectionDeserializer.java:78)
at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1703)
at com.caucho.hessian.io.JavaDeserializer$ObjectFieldDeserializer.deserialize(JavaDeserializer.java:387)
at com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:233)
at com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:157)
at com.caucho.hessian.io.SerializerFactory.readObject(SerializerFactory.java:376)
at com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessian2Input.java:2054)
at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1980)
at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1972)
at com.caucho.hessian.io.CollectionDeserializer.readList(CollectionDeserializer.java:78)
at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1703)
at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:220)
at $P