-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4284518
By: taskoba
After 15 days tring to understand and solve a LazyInitialization problem, i started to think that i should show the problem and the solution to the communit.
The catch:
I work in application witch access two databases. And i use hibernate+spring+acegi+ZK.
All the configuration needed to make the hibernate session open in presentation layer (ZK) were made, and are showed in http://www.zkoss.org/smalltalks/hibnsprn/hibn_sprn_zk.html.
But in no place is showed how we handle multiple SessionFactories, witch are necessary for multiple DB's the solution is to add on the web.xml the follow
configuration:
<filter>
<filter-name>{Your Filter Name}</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilt
er</filter-class>
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>{Your Session Factory Bean Name}</param-value>
</init-param>
</filter>
</filter-mapping>
<filter-mapping>
<filter-name>{Your Filter Name}</filter-name>
<url-pattern>{Your URL pattern needed to be "watched"}</url-pattern> </filter-mapping>
The above configuration is needed for each SessionFactory bean created.
This topic is doesn't apply only to ZK but to any presentation framework, but ZK is my favorite!
I hope that helps and save your time finding the solution.
Best Regards
taskoba
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4287399
By: henrichen
Hi taskoba,
Can you write the above to ZK's How-Tos. I am afraid that your contribution will be buried in this "forum sea" some days after :-).
http://en.wikibooks.org/wiki/ZK/How-Tos
/henri
Hello all,
I picked up this old thread. I started to work with hibernate for a while and as far as I just use one single database (==> just one hibernate.cfg.xml) the zkplus concept concept works fine .
Now I have a more complex situation and I have to access 4 different databases which means 4 hibernate???.cfg.xml files.
I have looked into the src of org.zkoss.zkplus.hibernate.HibernateUtil. It is possible to address a different file instead of hibernate.cfg.xml but I found no hint how to handle more then one hibernate.cfg.xml.
I hope someone else has solved that problem before !
BtW. I am NOT using spring, so any hint about zk + spring + hibernate will not fit.
Many thanks in advance!
Horst
Horst,
you can set the configuration file to any location , check this http://www.zkoss.org/javadoc/3.6.1/zk/org/zkoss/zkplus/hibernate/HibernateUtil.html
however I don't think hibernate.cfg.xml accepts more than 1 sessionFactory,
(search 'multiple sessionFactory hibernate.cfg.xml example' on google , you will find this)
and there is no multiple session factory concept in HibernateUtil.
so, if you don't want to write any custom code ,then you have no way to do this.
please post this to feature request , :D
Hi Dennis!
As I expected this answer after investigating the zkplus/hibernate/*.java sources and so I started to rewrite it :-(.
I will make my changes public here as soon as I am sure that it is stable, I think there will be more zk users who may run into the same trouble.
Kind regards
Horst
Horst,
I am very glad to see this contribution.
how about write a small talk (wiki)for it?
:)
Asked: 2007-04-27 17:20:39 +0800
Seen: 471 times
Last updated: Jun 08 '09