View Full Version : the right way to call hibernate in resin quercus php

05-28-2010, 04:09 AM
hi, I have java classes handle database using hibernate, my front using php to calling those APIs.
1. java class implement DAO pattern using hibernate to handle data access.
2. create service interface for php calling.
3. php front page calling those service interface.

my question is: the speed is extreamly slow, I think it caused by sessoion factory create and end at every php page. how could minimize the creation of session factory in php? could someone give me some guide line to follow?
I think if I am using structs or spring I have framework structure to control that. Because I like to use the php in front, and java backend, what should I do?

I have followed hibernate guideline that session factory will stay in current thread, only current thread terminates, session factory will release.
but in web environment, it looks to me that every php calling my java service API would envoke a new thread, when it quite, the thread terminates, so session factory will end.
Am I understand the flow correctly?

03-05-2011, 09:45 PM
I also found realy interesting usage of PHP application with hibernate ORM. I actualy using quercus in portlet in Liferay portal, and have same problem with hibernate entity manager.
What I do is that I create EntityManagerFactory on initialization of servlet and put it in application context. So every time I need entity manager I just call EntityManagerFactory factory and method createEntityManager(), so it is much faster and cheaper than calling it on every page.