openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <plins...@gmail.com>
Subject Re: svn commit: r554803 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql: DBDictionary.java RowImpl.java
Date Tue, 10 Jul 2007 21:55:57 GMT
Cool, sounds like a neat new feature. Which begs the question: what's
the plan for documenting it?

-Patrick

On 7/10/07, David Wisneski <wisneskid@gmail.com> wrote:
> Hi Patrick,
>
> The SQLServer specific stuff in RowImpl dealing with null values was
> already there in the code.  I did not add or change that.
>
> The change I made was to delegate to DBDictionary to generate the
> syntax of column names in UPDATE  WHERE clause.  When dealing with DB
> Generated values such as version column,  different db vendors have
> special keywords or functions to do comparision of the these db
> generated columns.  For example,  a normal column predicate would be
> <col_name> = ?   but for a dbgenerated column name the syntax might be
> ROW CHANGE TIMESTAMP FOR <table name> = ?
>
>
> On 7/9/07, Patrick Linskey <plinskey@gmail.com> wrote:
> > Some questions:
> >
> > 1. What is a platform-specific where column?
> >
> > 2. It's a bit disconcerting to see SQLServer-specific stuff in RowImpl
> > -- what are you trying to accomplish there? Maybe we can put that
> > logic into DBDictionary somehow. I think it's valuable to isolate all
> > of the database-specific craziness into DBDictionary, rather than
> > spreading it about.
> >
> > -Patrick
> >
> > On 7/9/07, wisneskid@apache.org <wisneskid@apache.org> wrote:
> > > Author: wisneskid
> > > Date: Mon Jul  9 19:28:11 2007
> > > New Revision: 554803
> > >
> > > URL: http://svn.apache.org/viewvc?view=rev&rev=554803
> > > Log:
> > > OPENJPA-266, extensibility for platform specific version column
> > > Passed TCK with Derby
> > >
> > > Modified:
> > >     openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
> > >     openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/RowImpl.java
> > >
> > > Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
> > > URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?view=diff&rev=554803&r1=554802&r2=554803
> > > ==============================================================================
> > > --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
> > > +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Mon Jul  9 19:28:11 2007
> > > @@ -3839,4 +3839,14 @@
> > >              this.bytes = bytes;
> > >          }
> > >      }
> > > +
> > > +    /**
> > > +     * Return version column name
> > > +     * @param column
> > > +     * @param tableAlias : this is needed for platform specific version column
> > > +     * @return
> > > +     */
> > > +    public String getVersionColumn(Column column, String tableAlias) {
> > > +        return column.toString();
> > > +    }
> > >  }
> > >
> > > Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/RowImpl.java
> > > URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/RowImpl.java?view=diff&rev=554803&r1=554802&r2=554803
> > > ==============================================================================
> > > --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/RowImpl.java
(original)
> > > +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/RowImpl.java
Mon Jul  9 19:28:11 2007
> > > @@ -20,6 +20,7 @@
> > >
> > >  import java.io.InputStream;
> > >  import java.io.Reader;
> > > +import java.lang.reflect.Method;
> > >  import java.math.BigDecimal;
> > >  import java.math.BigInteger;
> > >  import java.sql.Array;
> > > @@ -756,7 +757,7 @@
> > >              hasVal = true;
> > >          }
> > >
> > > -        appendWhere(buf);
> > > +        appendWhere(buf, dict);
> > >          return buf.toString();
> > >      }
> > >
> > > @@ -797,14 +798,14 @@
> > >          StringBuffer buf = new StringBuffer();
> > >          buf.append("DELETE FROM ").
> > >              append(dict.getFullName(getTable(), false));
> > > -        appendWhere(buf);
> > > +        appendWhere(buf, dict);
> > >          return buf.toString();
> > >      }
> > >
> > >      /**
> > >       * Appends the where clause onto the given sql buffer.
> > >       */
> > > -    private void appendWhere(StringBuffer buf) {
> > > +    private void appendWhere(StringBuffer buf, DBDictionary dict) {
> > >          boolean hasWhere = false;
> > >          for (int i = 0; i < _cols.length; i++) {
> > >              if (_vals[getWhereIndex(_cols[i])] == null)
> > > @@ -815,9 +816,13 @@
> > >              else
> > >                  buf.append(" AND ");
> > >
> > > +            // Get platform specific version column name
> > > +            if (_cols[i].getVersionStrategy() != null)
> > > +               buf.append(dict.getVersionColumn(_cols[i], _cols[i]
> > > +                   .getTableName())).append(" = ?");
> > >              // sqlserver seems to have problems using null parameters in the
> > >              // where clause
> > > -            if (_vals[getWhereIndex(_cols[i])] == NULL)
> > > +            else if (_vals[getWhereIndex(_cols[i])] == NULL)
> > >                  buf.append(_cols[i]).append(" IS NULL");
> > >              else if (_types[i] == RAW)
> > >                  buf.append(_cols[i]).append(" = ").append(_vals[i]);
> > >
> > >
> > >
> >
> >
> > --
> > Patrick Linskey
> > 202 669 5907
> >
>


-- 
Patrick Linskey
202 669 5907

Mime
View raw message