|
From: <php...@li...> - 2009-09-23 18:29:52
|
Hi, I'm in the process of evaluating the PHP/Java Bridge. My company wants to use it to leverage an existing set of data model classes we have created using Hibernate. I've successfully set up a test that is working fine, but I've come across something I'm concerned and a bit confused about and was hoping the list could help me. I've read the FAQ entry which states that all exceptions crossing the boundary must be declared, as well as a thread in the mailing list archives here: http://sourceforge.net/mailarchive/message.php?msg_id=3921.39923.qm%40web505 08.mail.re2.yahoo.com My concern is that this will prevent us from using the bridge in the way we have envisioned, so I'm asking for advice on how to handle it. We want to be able to perform arbitrary operations on our data model classes within the scope of a Hibernate transaction, using a pattern like the following: $factory = getSessionFactory(); //Hibernate session factory try { $factory->getCurrentSession()->beginTransaction(); //arbitrary code here $factory->getCurrentSession()->getTransaction()->commit(); } catch (JavaException $ex) { $factory->getCurrentSession()->getTransaction()->rollback(); throw $ex; } My concern is that there are several places within the arbitrary code sections where we are calling methods that throw unchecked exceptions that subclass RuntimeException. Most of our exceptions will occur during the commit, but not all of them. Is our approach even feasible with the bridge? We do not want to have to declare "throws RuntimeException" on hundreds of methods in our data model classes. Is there some other approach we could take, perhaps passing our arbitrary code as a closure to the java side and having a top level handler for all exceptions on the java side of things? I apologize if I am misunderstanding anything. I have been programming Java for a couple of years but so far I've only used basic servlets, no JEE containers or anything more complicated so I'm basically looking for guidance. Thanks in advance! Michael Sims |