You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by do...@cocoon.apache.org on 2004/12/06 13:29:53 UTC

[Cocoon Wiki] Updated: CocoonAndHibernateTutorial

   Date: 2004-12-06T04:29:52
   Editor: JohannesTextor <jc...@gmx.de>
   Wiki: Cocoon Wiki
   Page: CocoonAndHibernateTutorial
   URL: http://wiki.apache.org/cocoon/CocoonAndHibernateTutorial

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -103,7 +103,11 @@
 connection pooling right away. 
 
 Where we will do this is in the actual implementation of the {{{PersistenceFactory}}} interface, 
-in a class called {{{HibernateFactory}}} "(fellow Cocooners: is this good practice?)"
+in a class called {{{HibernateFactory}}} 
+
+'''IMPORTANT NOTE:''' Make sure you check out the comments in {{{initialize()}}} for instructions on how to add persistent
+classes. If you are using this to port an existing Hibernate / Cocoon application to the Cocoon 
+connection pool, you will need to change that part according to your configuration. 
 
 {{{
 package org.test;
@@ -180,9 +184,23 @@
         try {
               cfg = new net.sf.hibernate.cfg.Configuration();
 
-	      // classes to persist will be added here later 
-							
-              sf = cfg.buildSessionFactory();
+              /* ***** ADD PERSISTENT CLASSES, VARIANT 1 *****
+	      // persistent classes can be added here using 
+
+              // cfg.addClass(org.test.myClass.class); 
+
+              // Make sure the corresponding .class and .hbm.xml files are located in 
+              // (the same directory of) your classpath (e.g. WEB-INF/classes) 
+              sf = cfg.buildSessionFactory()
+
+              /* ***** ADD PERSISTENT CLASSES, VARIANT 2 *****
+	      // alternatively, you might be using a hibernate.cfg.xml file to load mappings,
+              // then use the following line instead: 
+
+              // sf = cfg.configure().buildSessionFactory;
+
+              // no additional cfg.addClass(...) statements needed, since you can define
+              // mappings in the XML config file 
         }
         catch ( Exception e) {
               getLogger().error("Hibernate:" + e.getMessage());