Return-Path: Delivered-To: apmail-xml-cocoon-dev-archive@xml.apache.org Received: (qmail 26529 invoked by uid 500); 19 Jun 2003 07:19:07 -0000 Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-dev@xml.apache.org Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 26507 invoked from network); 19 Jun 2003 07:19:06 -0000 Received: from unknown (HELO mail.cbim.it) (212.131.130.82) by daedalus.apache.org with SMTP; 19 Jun 2003 07:19:06 -0000 Received: from cuprouter.cbim.it (cuprouter.cbim.it [192.168.4.10]) by mail.cbim.it (8.11.6/8.11.0) with ESMTP id h5J7ga630477 for ; Thu, 19 Jun 2003 09:42:36 +0200 Received: from cbim.it (caterina.cbim.it [192.168.4.42]) by cuprouter.cbim.it (8.9.3/8.9.3) with ESMTP id JAA07034 for ; Thu, 19 Jun 2003 09:20:18 +0200 Message-ID: <3EF16426.3010906@cbim.it> Date: Thu, 19 Jun 2003 09:20:06 +0200 From: Ugo Cei Organization: C.B.I.M. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030314 X-Accept-Language: en-us, en MIME-Version: 1.0 To: cocoon-dev@xml.apache.org Subject: Re: Hibernate sessions (was Re: [vote results] FOM) References: <8D258AC6-A1D9-11D7-99B8-0003935AD2EE@media.demon.co.uk> In-Reply-To: <8D258AC6-A1D9-11D7-99B8-0003935AD2EE@media.demon.co.uk> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Jeremy Quinn wrote: > is that: > > var session = Package.package.name.Persistence.getSession(); ? Yep. > Would you do something like this, if you wanted to use Transactions? : > > var transaction; > try { > transaction = session.beginTransaction(); > >> session.saveOrUpdate(model); > > > transaction.commit(); > } catch (e) { > Persistence.rollback(transaction); > log.error(e.getMessage()); > // send an error view > } Yes. What's important is that you must perform your transaction in the scope of a single HTTP request, otherwise you'll have to use another strategy. > Would you consider doing something like the above from inside a sendView > validation function, adding a violation if you had to roll back? Haven't thought about it. > By what I understand now ..... what I require is the Persistence class > from the page you sent me and a configuration to add to web.xml. What I > am not sure I understand is what that configuration should be. First of all, you need a Servlet 2.3 compliant container. Recent versions of Jetty or Tomcat are OK. Then you need to patch Cocoon's web.xml file to refer to the 2.3 DTD: Then, as first children of the element add the following lines: HibernateFilter it.cbim.bpa.model.util.Persistence HibernateFilter / As far as JNDI is concerned, I've removed all JNDI code from my Persistence class and simplified it a little. I'm sending you privately the class. Ugo -- Ugo Cei - Consorzio di Bioingegneria e Informatica Medica P.le Volontari del Sangue, 2 - 27100 Pavia - Italy Phone: +39.0382.525100 - E-mail: u.cei@cbim.it