You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2003/04/24 00:02:29 UTC

cvs commit: jakarta-turbine-fulcrum/src/test/org/apache/fulcrum/db HibernateServiceTest.java

epugh       2003/04/23 15:02:28

  Modified:    .        project.xml
               src/java/org/apache/fulcrum/db HibernateService.java
               src/test/org/apache/fulcrum/db HibernateServiceTest.java
  Log:
  Updated the HibernateService to work with Hibernate 2.0.  While still in beta, 
  that is where all future work will be.
  
  Revision  Changes    Path
  1.65      +14 -4     jakarta-turbine-fulcrum/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/project.xml,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- project.xml	23 Apr 2003 12:18:14 -0000	1.64
  +++ project.xml	23 Apr 2003 22:02:28 -0000	1.65
  @@ -139,6 +139,16 @@
         <version>2.2</version>
       </dependency>
       <dependency>
  +      <id>commons-beanutils</id>
  +      <version>1.6.1</version>
  +      <url>http://jakarta.apache.org/commons/beanutils.html</url>
  +    </dependency>    
  +    <dependency>
  +      <id>cglib</id>
  +	  <jar>cglib.jar</jar>
  +      <url>http://cglib.sf.net/</url>
  +    </dependency>    
  +    <dependency>
         <id>commons-collections</id>
         <version>2.1</version>
         <url>http://jakarta.apache.org/commons/collections.html</url>
  @@ -188,7 +198,7 @@
       </dependency>
       <dependency>
         <id>dom4j</id>
  -      <version>1.3</version>
  +      <version>1.4</version>
         <url>http://www.dom4j.org/</url>
       </dependency>
       <dependency>
  @@ -295,7 +305,7 @@
       </dependency>
       <dependency>
         <id>hibernate</id>      
  -      <version>1.2.4</version>
  +      <version>2.0-beta5</version>
         <properties>        
         <war.bundle.jar>true</war.bundle.jar>
         </properties>
  @@ -343,7 +353,7 @@
             <directory>src/test</directory> 
             <targetPath></targetPath> 
             <includes>
  -            <include>hibernate.properties</include> 
  +            <include>hibernate.cfg.xml</include> 
             </includes>
           </resource>
         </resources>
  @@ -355,7 +365,7 @@
           <include>**/avalon-roles.xml</include>
         </includes>
         <excludes>
  -        <exclude>**/hibernate.properties</exclude>
  +        <exclude>**/hibernate.cfg.xml</exclude>
         </excludes>
       </resources>
   
  
  
  
  1.2       +21 -21    jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/db/HibernateService.java
  
  Index: HibernateService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/db/HibernateService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HibernateService.java	22 Apr 2003 22:23:36 -0000	1.1
  +++ HibernateService.java	23 Apr 2003 22:02:28 -0000	1.2
  @@ -66,13 +66,13 @@
   import org.apache.torque.Torque;
   import org.apache.torque.adapter.DB;
   import org.apache.torque.map.DatabaseMap;
  -
  -import cirrus.hibernate.Hibernate;
  -import cirrus.hibernate.Datastore;
  -import cirrus.hibernate.Session;
  -import cirrus.hibernate.SessionFactory;
  -import cirrus.hibernate.sql.Dialect;
  -import cirrus.hibernate.tools.SchemaExport;
  +import net.sf.hibernate.*;
  +import net.sf.hibernate.Session;
  +import net.sf.hibernate.SessionFactory;
  +import net.sf.hibernate.cfg.Configuration;
  +import net.sf.hibernate.dialect.*;
  +import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
  +import net.sf.hibernate.HibernateException;
   
   /**
    * Fulcrum's default implementation of the Hibernate Object Modeling tool.
  @@ -83,7 +83,7 @@
   public class HibernateService extends AbstractLogEnabled implements Initializable, Configurable, Startable, Component
   {
       private String xmlFile;
  -    private Datastore datastore;
  +    private net.sf.hibernate.cfg.Configuration configuration;
       private SessionFactory sessionFactory;
   
       /** Avalon role - used to id the component within the manager */
  @@ -91,16 +91,16 @@
   
       public static final String SERVICE_NAME = "HibernateService";
       public static final String XML_FILE = "xmlFile";
  -    public Datastore getDatastore()
  +    public net.sf.hibernate.cfg.Configuration getConfiguration()
       {
  -        return datastore;
  +        return configuration;
       }
   
       /** 
        * returns a Hibernate Session object that can then be used from now on! 
        * 
        */
  -    public Session openSession() throws java.sql.SQLException
  +    public Session openSession() throws HibernateException
       {
           return sessionFactory.openSession();
       }
  @@ -114,12 +114,13 @@
       {
           try
           {
  -            getLogger().info("Preparing HibernateService with xml file " + xmlFile);
  -            datastore = Hibernate.createDatastore();
  -            datastore.storeFile(xmlFile);
  +            
  +            //getLogger().info("Preparing HibernateService with xml file " + xmlFile);
  +            configuration =new net.sf.hibernate.cfg.Configuration().configure();
  +            
               
               //      Then build a session to the database
  -            sessionFactory = datastore.buildSessionFactory();
  +            sessionFactory = configuration.buildSessionFactory();
           }
           catch (Exception e)
           {
  @@ -130,14 +131,13 @@
       /**
        * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
        */
  -    public void configure(Configuration configuration) throws ConfigurationException
  +    public void configure(org.apache.avalon.framework.configuration.Configuration configuration) throws ConfigurationException
       {
           getLogger().info("Configuring HibernateService");
           xmlFile = configuration.getAttribute(XML_FILE, null);
  -
  -        if (xmlFile == null)
  -        {
  -            throw new ConfigurationException("You must provide a the xml file to load Hibernate mappings from!");
  +        
  +        if (xmlFile == null){
  +            getLogger().warn("No XmlFile provided for configuration.");
           }
   
       }
  
  
  
  1.2       +7 -7      jakarta-turbine-fulcrum/src/test/org/apache/fulcrum/db/HibernateServiceTest.java
  
  Index: HibernateServiceTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/test/org/apache/fulcrum/db/HibernateServiceTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HibernateServiceTest.java	22 Apr 2003 22:23:36 -0000	1.1
  +++ HibernateServiceTest.java	23 Apr 2003 22:02:28 -0000	1.2
  @@ -1,11 +1,11 @@
   package org.apache.fulcrum.db;
   
  -import org.apache.plexus.PlexusTestCase;
  +import net.sf.hibernate.Session;
  +import net.sf.hibernate.SessionFactory;
  +import net.sf.hibernate.cfg.*;
  +import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
   
  -import cirrus.hibernate.Datastore;
  -import cirrus.hibernate.Session;
  -import cirrus.hibernate.SessionFactory;
  -import cirrus.hibernate.tools.SchemaExport;
  +import org.apache.plexus.PlexusTestCase;
   
   /**
    * HibernateServiceTest
  @@ -34,9 +34,9 @@
   
           HibernateService hibernateService = (HibernateService) getComponent(HibernateService.ROLE);
   
  -        Datastore ds = hibernateService.getDatastore();
  +        Configuration c = hibernateService.getConfiguration();
   
  -        new SchemaExport(ds).create(true, true);
  +        new SchemaExport(c).create(true, true);
   
           Labor labor = new Labor();
           Labor labor2 = new Labor();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-turbine-fulcrum/src/test/org/apache/fulcrum/db HibernateServiceTest.java

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
epugh@apache.org writes:

>  +    <dependency>
>  +      <id>cglib</id>
>  +	  <jar>cglib.jar</jar>
>  +      <url>http://cglib.sf.net/</url>
>  +    </dependency>    

-1 on that. Either get something with a version or let the
maven people put a snapshot with the yyyymmdd.hhmmss notation
in the repository. But I will not go the way to allow unversioned
jars into the dependencies. Along this way lies madness. 

We did the same thing for cryptix and the various Sun libs. Either get
a versioned jar or don't use it.

	Regards
		Henning

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

Java, perl, Solaris, Linux, xSP Consulting, Web Services 
freelance consultant -- Jakarta Turbine Development  -- hero for hire

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org