db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject cvs commit: db-ojb/profile hsqldb-commons-sql.profile
Date Sat, 14 Aug 2004 20:09:38 GMT
tomdz       2004/08/14 13:09:38

  Modified:    src/java/org/apache/ojb/broker/util/dbhandling DataSet.java
                        CommonsSqlDataHandling.java
                        CommonsSqlDatabaseHandling.java
                        DatabaseHandlingTask.java
               lib      commons-sql-1.0-dev.jar
               profile  hsqldb-commons-sql.profile
  Log:
  Updated to new commons-sql version
  Added support for specification of sql builder properties in the ant task
  
  Revision  Changes    Path
  1.3       +5 -4      db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/DataSet.java
  
  Index: DataSet.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/DataSet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DataSet.java	12 Aug 2004 18:21:14 -0000	1.2
  +++ DataSet.java	14 Aug 2004 20:09:38 -0000	1.3
  @@ -24,6 +24,7 @@
   import javax.sql.DataSource;
   
   import org.apache.commons.beanutils.DynaBean;
  +import org.apache.commons.sql.builder.SqlBuilder;
   import org.apache.commons.sql.dynabean.DynaSql;
   import org.apache.commons.sql.model.Database;
   
  @@ -53,9 +54,9 @@
        * @param db     The database model
        * @param writer The output stream
        */
  -    public void createInsertionSql(Database db, Writer writer) throws IOException
  +    public void createInsertionSql(Database db, SqlBuilder builder, Writer writer) throws
IOException
       {
  -        DynaSql      dynaSql = new DynaSql();
  +        DynaSql dynaSql = new DynaSql(builder);
   
           dynaSql.setDatabase(db);
           for (Iterator it = _beans.iterator(); it.hasNext();)
  @@ -74,9 +75,9 @@
        * @param ds The datasource pointing to the actual database
        * @param db The database model
        */
  -    public void insert(DataSource ds, Database db) throws SQLException
  +    public void insert(DataSource ds, SqlBuilder builder, Database db) throws SQLException
       {
  -        DynaSql      dynaSql = new DynaSql(ds, db);
  +        DynaSql dynaSql = new DynaSql(builder, ds, db);
   
           for (Iterator it = _beans.iterator(); it.hasNext();)
           {
  
  
  
  1.5       +9 -5      db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/CommonsSqlDataHandling.java
  
  Index: CommonsSqlDataHandling.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/CommonsSqlDataHandling.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CommonsSqlDataHandling.java	12 Aug 2004 18:21:14 -0000	1.4
  +++ CommonsSqlDataHandling.java	14 Aug 2004 20:09:38 -0000	1.5
  @@ -29,6 +29,7 @@
   import org.apache.commons.digester.ExtendedBaseRules;
   import org.apache.commons.digester.Rule;
   import org.apache.commons.digester.RuleSetBase;
  +import org.apache.commons.sql.builder.SqlBuilder;
   import org.apache.commons.sql.dynabean.DynaSql;
   import org.apache.commons.sql.model.Column;
   import org.apache.commons.sql.model.Database;
  @@ -52,7 +53,7 @@
   
           public DynaFactoryCreateRule()
           {
  -            _dynaSql = new DynaSql();
  +            _dynaSql = new DynaSql(CommonsSqlDataHandling.this._builder);
               _dynaSql.setDatabase(CommonsSqlDataHandling.this._db);
           }
   
  @@ -110,6 +111,8 @@
   
       /** The database model */
       private Database _db;
  +    /** The sql builder */
  +    private SqlBuilder _builder;
       /** The prepared model */
       private PreparedModel _preparedModel;
       /** The digester for parsing the XML */
  @@ -121,9 +124,10 @@
        * @param db    The database model
        * @param model The model
        */
  -    public CommonsSqlDataHandling(Database db, DescriptorRepository model)
  +    public CommonsSqlDataHandling(Database db, SqlBuilder builder, DescriptorRepository
model)
       {
           _db            = db;
  +        _builder       = builder;
           _preparedModel = new PreparedModel(model, db);
           _digester      = new Digester();
           _digester.setEntityResolver(new EntityResolver() {
  @@ -224,7 +228,7 @@
           {
               DataSet set = (DataSet)_digester.parse(input);
   
  -            set.createInsertionSql(_db, output);
  +            set.createInsertionSql(_db, _builder, output);
           }
           catch (Exception ex)
           {
  @@ -253,9 +257,9 @@
       {
           try
           {
  -            DataSet      set    = (DataSet)_digester.parse(input);
  +            DataSet set = (DataSet)_digester.parse(input);
               
  -            set.insert(ds, _db);
  +            set.insert(ds, _builder, _db);
           }
           catch (Exception ex)
           {
  
  
  
  1.8       +7 -6      db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/CommonsSqlDatabaseHandling.java
  
  Index: CommonsSqlDatabaseHandling.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/CommonsSqlDatabaseHandling.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CommonsSqlDatabaseHandling.java	8 Aug 2004 21:14:18 -0000	1.7
  +++ CommonsSqlDatabaseHandling.java	14 Aug 2004 20:09:38 -0000	1.8
  @@ -74,6 +74,7 @@
        */
       private void initPlatformMapping()
       {
  +        _platformToDatabaseType.put("Cloudscape",  "cloudscape");
           _platformToDatabaseType.put("Db2",         "db2");
           _platformToDatabaseType.put("Firebird",    "firebird");
           _platformToDatabaseType.put("Hsqldb",      "hsqldb");
  @@ -304,7 +305,7 @@
           }
           catch (NoSuchMethodException ex)
           {
  -           _log.warn("The builder for database "+_builder.getDatabaseName()+" does not
support the property "+propName); 
  +           //_log.info("The builder for database "+_builder.getDatabaseName()+" does not
support the property "+propName); 
           }
           catch (Exception ex)
           {
  @@ -434,7 +435,7 @@
        */
       public void insertData(Reader reader) throws IOException, DatabaseHandlingException
       {
  -        new CommonsSqlDataHandling(_schema, _model).insertData(reader, getDataSource());
  +        new CommonsSqlDataHandling(_schema, _builder, _model).insertData(reader, getDataSource());
       }
   
       /* (non-Javadoc)
  @@ -443,7 +444,7 @@
       public void insertData(String srcDir, String listOfFilenames) throws IOException, DatabaseHandlingException
       {
           DataSource             dataSource   = getDataSource();
  -        CommonsSqlDataHandling dataHandling = new CommonsSqlDataHandling(_schema, _model);
  +        CommonsSqlDataHandling dataHandling = new CommonsSqlDataHandling(_schema, _builder,
_model);
           StringTokenizer        tokenizer    = new StringTokenizer(listOfFilenames, ",");
           String                 baseDir      = ((srcDir != null) && (srcDir.length()
> 0) ? srcDir : ".") + "/";
           String                 token;
  @@ -464,7 +465,7 @@
        */
       public void getInsertDataSql(Reader reader, Writer writer) throws DatabaseHandlingException
       {
  -        new CommonsSqlDataHandling(_schema, _model).getInsertDataSql(reader, writer);
  +        new CommonsSqlDataHandling(_schema, _builder, _model).getInsertDataSql(reader,
writer);
       }
   
       /* (non-Javadoc)
  @@ -472,7 +473,7 @@
        */
       public void getInsertDataSql(String srcDir, String listOfFilenames, Writer writer)
throws IOException, DatabaseHandlingException
       {
  -        CommonsSqlDataHandling dataHandling = new CommonsSqlDataHandling(_schema, _model);
  +        CommonsSqlDataHandling dataHandling = new CommonsSqlDataHandling(_schema, _builder,
_model);
           StringTokenizer        tokenizer    = new StringTokenizer(listOfFilenames, ",");
           String                 baseDir      = ((srcDir != null) && (srcDir.length()
> 0) ? srcDir : ".") + "/";
           String                 token;
  @@ -493,6 +494,6 @@
        */
       public void getDataDTD(Writer writer) throws DatabaseHandlingException
       {
  -        new CommonsSqlDataHandling(_schema, _model).getDataDTD(writer);
  +        new CommonsSqlDataHandling(_schema, _builder, _model).getDataDTD(writer);
       }
   }
  
  
  
  1.8       +16 -7     db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/DatabaseHandlingTask.java
  
  Index: DatabaseHandlingTask.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/dbhandling/DatabaseHandlingTask.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DatabaseHandlingTask.java	12 Aug 2004 18:21:14 -0000	1.7
  +++ DatabaseHandlingTask.java	14 Aug 2004 20:09:38 -0000	1.8
  @@ -444,6 +444,8 @@
       private ArrayList _actions = new ArrayList();
       /** Database properties */
       private ArrayList _dbProps = new ArrayList();
  +    /** The OJB instance */
  +    private OJB _ojb;
   
       /**
        * Sets the name of the handling to use.
  @@ -744,10 +746,10 @@
               }
   
               // this effectively initializes OJB
  -            OJB ojb = new OJB();
  -            PersistenceBrokerFactory.setOjb(ojb);
  +            _ojb = new OJB();
  +            PersistenceBrokerFactory.setOjb(_ojb);
   
  -            MetadataManager     metadataManager = ojb.getMetadataManager();
  +            MetadataManager     metadataManager = _ojb.getMetadataManager();
               RepositoryPersistor persistor       = new RepositoryPersistor();
   
               if (_repositoryFile != null)
  @@ -823,9 +825,16 @@
       {
           try
           {
  -            Class handlerClass = Class.forName(_handlerClassName);
  +            Class            handlerClass = Class.forName(_handlerClassName);
  +            DatabaseHandling handler      = (DatabaseHandling)handlerClass.newInstance();
   
  -            return (DatabaseHandling)handlerClass.newInstance();
  +            for (Iterator it = _dbProps.iterator(); it.hasNext();)
  +            {
  +                DatabaseProperty prop = (DatabaseProperty)it.next();
  +
  +                handler.setDatabaseProperty(prop.getName(), prop.getValue());
  +            }
  +            return handler;
           }
           catch (Exception ex)
           {
  @@ -895,7 +904,7 @@
                   addIncludes(handling, (FileSet)it.next());
               }
   
  -            ConnectionRepository connRep = MetadataManager.getInstance().connectionRepository();
  +            ConnectionRepository connRep = _ojb.getMetadataManager().connectionRepository();
               PBKey                pbKey   = null;
   
               if ((_jcdAlias == null) || (_jcdAlias.length() == 0))
  @@ -915,7 +924,7 @@
                   }
               }
               handling.setConnection(connRep.getDescriptor(pbKey));
  -            handling.setMetadata(MetadataManager.getInstance().getGlobalRepository());
  +            handling.setMetadata(_ojb.getMetadataManager().getGlobalRepository());
               
               for (Iterator it = _actions.iterator(); it.hasNext();)
               {
  
  
  
  1.9       +354 -329  db-ojb/lib/commons-sql-1.0-dev.jar
  
  	<<Binary file>>
  
  
  1.2       +6 -0      db-ojb/profile/hsqldb-commons-sql.profile
  
  Index: hsqldb-commons-sql.profile
  ===================================================================
  RCS file: /home/cvs/db-ojb/profile/hsqldb-commons-sql.profile,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- hsqldb-commons-sql.profile	29 Jul 2004 20:33:43 -0000	1.1
  +++ hsqldb-commons-sql.profile	14 Aug 2004 20:09:38 -0000	1.2
  @@ -91,6 +91,12 @@
   databasePassword =
   databaseHost = 127.0.0.1
   
  +#
  +# commons-sql database builder properties
  +#
  +# Specifies the locale for date/number generation
  +#valueLocale=en_US
  +
   
   # Tells JDBC task that javaName attribute for the tables and columns
   # should be made same as SQL name.
  
  
  

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


Mime
View raw message