关于ssh整合多数据源的问题,好像不能持久化JavaBean(不同数据库)

joni_eyes 2009-06-03
hibernate多数据库 表之间的关联不能持久化吗。
是SessionFactory的关系还是事务的关系?
比如:数据库A中的表user类 one-to-one 关联数据库B中的表Department类,我在user.hbm.xml映射时<one-to-one name="department" class="com.joni.demo.model.Department"></one-to-one>,启动tomcat报错:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory2' defined in URL [file:/E:/Program%20Files/apache-tomcat-6.0.18/webapps/GM/WEB-INF/classes/applicationContext-sessionFactory.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: persistent class not known: com.joni.demo.model.Department
如果不同数据库没有关联关系,我测试过 切换SessionsFactory时是可以运行的。

我最近在做一个游戏数据管理系统,要跨服务器读数据。希望能尽快回应,谢谢
sandylxh 2009-08-12
sandylxh 2009-08-12
引用
[img][/img]
[img][/img][url][/url]
sandylxh 2009-08-12
我也正在找
w2gavin 2009-08-26
个人认为是配置的问题,one-to-one标签的两种用法:
1.一端使用:
       <one-to-one name=.. class=.. constrained="true">
  另一端可以是:
       <one-to-one name=..>
2.在<many-to-one>配置中unique="true":
   一端使用:
       <many-to-one name=.. class=.. unique=true not-null=true>
   另一端使用:
       <one-to-one name=.. property-ref=..>
younglibin 2009-09-14
读过hibernate映射,感觉 楼上方法 有道理! 不过 楼主  好强!我还没遇到 跨数据库问题!等哪天用到了!来这请教你!
Global site tag (gtag.js) - Google Analytics