commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Anderson" <t...@intalio.com>
Subject RE: cvs commit: jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder PostgreSqlBuilder.java
Date Mon, 23 Sep 2002 23:33:35 GMT
This is the sort of change I would like to see avoided -
commons-sql will end up full of *Builder classes which work for
one version of a database, and not another. What happens if the next release
of postgres supports varbinary?

What I am aiming at with the proposal described in
http://www.mail-archive.com/commons-dev%40jakarta.apache.org/msg08742.html
should eventually avoid the need for this.
Ideally, all vendor specific features should be described in XML:
. there is only one main concrete SqlBuilder implementation
. SqlBuilderFactory supplies the configuration to the SqlBuilder
  based on a database name, and optionally, version.
. removes the need for users to create and register *Builder implementations
  for vendor X - instead, all that is required is a configuration to be
  located in /META-INF/<vendor x> which will by dynamically discovered and
loaded
  by SqlBuilderFactory

I'll modify my proposal and send out an updated version towards the end of
the
week, but I'd appreciate feedback on the existing implementation.

Regards,

Tim


> -----Original Message-----
> From: thorhauer@apache.org [mailto:thorhauer@apache.org]
> Sent: Tuesday, September 24, 2002 2:53 AM
> To: jakarta-commons-sandbox-cvs@apache.org
> Subject: cvs commit:
> jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder
> PostgreSqlBuilder.java
>
>
> thorhauer    2002/09/23 09:53:24
>
>   Modified:    sql/src/java/org/apache/commons/sql/builder
>                         PostgreSqlBuilder.java
>   Log:
>   - adding support for postgres oid type since they dont support
> blob or varbinary
>
>   - fixing serial column creation so that postgres takes care of
> most of the work
>
>   Revision  Changes    Path
>   1.2       +53 -3
> jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builde
r/PostgreSqlBuilder.java
>
>   Index: PostgreSqlBuilder.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-commons-sandbox/sql/src/java/org/apache/commons/
sql/builder/PostgreSqlBuilder.java,v
>   retrieving revision 1.1
>   retrieving revision 1.2
>   diff -u -r1.1 -r1.2
>   --- PostgreSqlBuilder.java	20 Sep 2002 20:50:51 -0000	1.1
>   +++ PostgreSqlBuilder.java	23 Sep 2002 16:53:24 -0000	1.2
>   @@ -58,6 +58,7 @@
>
>    package org.apache.commons.sql.builder;
>
>   +import org.apache.commons.sql.model.Column;
>    import java.io.IOException;
>
>    /**
>   @@ -74,6 +75,55 @@
>        }
>
>        protected void printAutoIncrementColumn() throws IOException {
>   -        print( "DEFAULT NEXTVAL('serial')" );
>   +        print(" ");
>   +        print("serial");
>   +        print(" ");
>   +
>   +    }
>   +
>   +    /**
>   +     * Outputs the DDL to add a column to a table.
>   +     */
>   +    public void createColumn(Column column) throws IOException {
>   +        this.column = column;
>   +        print(column.getName());
>   +        print(" ");
>   +        if (column.isAutoIncrement()) {
>   +            printAutoIncrementColumn();
>   +        }
>   +        else
>   +        {
>   +
>   +            print(getSqlType(column));
>   +            print(" ");
>   +
>   +            if (column.getDefaultValue() != null)
>   +            {
>   +              print("DEFAULT '" + column.getDefaultValue() + "' ");
>   +            }
>   +            if (column.isRequired()) {
>   +                printNotNullable();
>   +            }
>   +            else {
>   +                printNullable();
>   +            }
>   +            print(" ");
>   +        }
>        }
>   +
>   +    /**
>   +     * @return the full SQL type string including the size
>   +     */
>   +    protected String getSqlType(Column column) {
>   +
>   +        if (column.getTypeString().equalsIgnoreCase("VARBINARY"))
>   +        {
>   +            return "OID";
>   +        }
>   +        else
>   +        {
>   +            return column.getTypeString();
>   +        }
>   +    }
>   +
>    }
>
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message