|
From: <php...@li...> - 2009-09-23 18:36:34
|
I would recommend to encapsulate your arbitrary code inside a java method and simply call the method from the php-side of the bridge, instead of rebuilding it in php. ~ dominik On Wed, Sep 23, 2009 at 8:10 PM, <php...@li...> wrote: > 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 > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > |