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:
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
Then, as first children of the <web-app> element add the following lines:
<filter> <filter-name>HibernateFilter</filter-name> <!-- change this to the name of your filter class --> <filter-class>it.cbim.bpa.model.util.Persistence</filter-class> </filter>
<filter-mapping> <filter-name>HibernateFilter</filter-name> <url-pattern>/</url-pattern> </filter-mapping>
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: [EMAIL PROTECTED]