openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Srinivasa Segu" <ss...@bea.com>
Subject RE: svn commit: r509473 - in /incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc: meta/strats/StateComparisonVersionStrategy.java sql/PrimaryRow.java sql/RowImpl.java sql/SecondaryRow.java
Date Tue, 20 Feb 2007 18:00:12 GMT
Sure, will do. Thanks for the info. 

-----Original Message-----
From: Kevin Sutter [mailto:kwsutter@gmail.com] 
Sent: Tuesday, February 20, 2007 3:43 AM
To: open-jpa-dev@incubator.apache.org
Subject: Re: svn commit: r509473 - in
/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/j
dbc: meta/strats/StateComparisonVersionStrategy.java sql/PrimaryRow.java
sql/RowImpl.java sql/SecondaryRow.java

Segu,
In the future, could you please reference the JIRA Issue in your commit
message?  Just a simple "OPENJPA-155. Capturing reference to the
Column[]..." would automatically put the SVN changed lines into the Jira
Issue for easy reference.  Thanks.

Kevin

On 2/20/07, ssegu@apache.org <ssegu@apache.org> wrote:
>
> Author: ssegu
> Date: Tue Feb 20 00:59:10 2007
> New Revision: 509473
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=509473
> Log:
> Capturing reference to the Column[] at the creation time in the
RowImpl
> instead of the Table, to work with DynamicSchemaFactory where the
Table's
> columns can get modified after the creation of the RowImpl before the
flush.
>
> Modified:
>
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/meta/strats/StateComparisonVersionStrategy.java
>
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/sql/PrimaryRow.java
>
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/sql/RowImpl.java
>
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/sql/SecondaryRow.java
>
> Modified:
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/meta/strats/StateComparisonVersionStrategy.java
> URL:
>
http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/ma
in/java/org/apache/openjpa/jdbc/meta/strats/StateComparisonVersionStrate
gy.java?view=diff&rev=509473&r1=509472&r2=509473
>
>
========================================================================
======
> ---
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/meta/strats/StateComparisonVersionStrategy.java
> (original)
> +++
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/meta/strats/StateComparisonVersionStrategy.java
> Tue Feb 20 00:59:10 2007
> @@ -223,7 +223,11 @@
>          implements RowManager {
>
>          private CustomUpdate(Table table) {
> -            super(table, Row.ACTION_UPDATE);
> +            this(table.getColumns());
> +        }
> +
> +        private CustomUpdate(Column[] cols) {
> +            super(cols, Row.ACTION_UPDATE);
>          }
>
>          /**
> @@ -252,8 +256,8 @@
>              return buf.toString();
>          }
>
> -        protected RowImpl newInstance(Table table, int action) {
> -            return new CustomUpdate(table);
> +        protected RowImpl newInstance(Column[] cols, int action) {
> +            return new CustomUpdate(cols);
>          }
>
>          /////////////////////////////
>
> Modified:
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/sql/PrimaryRow.java
> URL:
>
http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/ma
in/java/org/apache/openjpa/jdbc/sql/PrimaryRow.java?view=diff&rev=509473
&r1=509472&r2=509473
>
>
========================================================================
======
> ---
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/sql/PrimaryRow.java
> (original)
> +++
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/sql/PrimaryRow.java
> Tue Feb 20 00:59:10 2007
> @@ -59,7 +59,11 @@
>       * Constructor; supply table and action.
>       */
>      public PrimaryRow(Table table, int action, OpenJPAStateManager
owner)
> {
> -        super(table, action);
> +        this(table.getColumns(), action, owner);
> +    }
> +
> +    protected PrimaryRow(Column[] cols, int action,
OpenJPAStateManager
> owner) {
> +        super(cols, action);
>          _pk = owner;
>      }
>
> @@ -385,8 +389,8 @@
>          return super.generateSQL(dict);
>      }
>
> -    protected RowImpl newInstance(Table table, int action) {
> -        return new PrimaryRow(table, action, _pk);
> +    protected RowImpl newInstance(Column[] cols, int action) {
> +        return new PrimaryRow(cols, action, _pk);
>      }
>
>      public void copyInto(RowImpl row, boolean whereOnly) {
>
> Modified:
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/sql/RowImpl.java
> URL:
>
http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/ma
in/java/org/apache/openjpa/jdbc/sql/RowImpl.java?view=diff&rev=509473&r1
=509472&r2=509473
>
>
========================================================================
======
> ---
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/sql/RowImpl.java
> (original)
> +++
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/sql/RowImpl.java
> Tue Feb 20 00:59:10 2007
> @@ -59,7 +59,7 @@
>      private static final int RAW = Integer.MIN_VALUE;
>
>      protected byte flags = 0;
> -    private final Table _table;
> +    private final Column[] _cols;
>      private final int _action;
>      private final Object[] _vals;
>      private final int[] _types;
> @@ -73,12 +73,16 @@
>       * @param action the action on the row
>       */
>      public RowImpl(Table table, int action) {
> -        _table = table;
> +        this(table.getColumns(), action);
> +    }
> +
> +    protected RowImpl(Column[] cols, int action) {
> +        _cols = cols;
>          _action = action;
>
>          // we need room for values and types for all columns; if an
> update or
>          // delete, then we need to double that for where column
> conditions
> -        int len = table.getColumns().length;
> +        int len = _cols.length;
>          if (action != ACTION_INSERT)
>              len *= 2;
>          _vals = new Object[len];
> @@ -86,7 +90,11 @@
>      }
>
>      public Table getTable() {
> -        return _table;
> +        return _cols[0].getTable();
> +    }
> +
> +    public Column[] getColumns() {
> +        return _cols;
>      }
>
>      public int getAction() {
> @@ -168,7 +176,7 @@
>          boolean set)
>          throws SQLException {
>          ClassMapping mapping = (ClassMapping) sm.getMetaData();
> -        while (mapping.getTable() != _table)
> +        while (mapping.getTable() != getTable())
>              mapping = mapping.getPCSuperclassMapping();
>          Column[] cols = mapping.getPrimaryKeyColumns();
>          flushJoinValues(sm, cols, cols, io, set);
> @@ -730,15 +738,14 @@
>          buf.append("UPDATE ").append(dict.getFullName(getTable(),
> false)).
>              append(" SET ");
>
> -        Column[] cols = getTable().getColumns();
>          boolean hasVal = false;
> -        for (int i = 0; i < cols.length; i++) {
> +        for (int i = 0; i < _cols.length; i++) {
>              if (_vals[i] == null)
>                  continue;
>
>              if (hasVal)
>                  buf.append(", ");
> -            buf.append(cols[i]);
> +            buf.append(_cols[i]);
>              if (_types[i] == RAW)
>                  buf.append(" = ").append(_vals[i]);
>              else
> @@ -759,9 +766,8 @@
>          buf.append("INSERT INTO ").
>              append(dict.getFullName(getTable(), false)).append(" (");
>
> -        Column[] cols = getTable().getColumns();
>          boolean hasVal = false;
> -        for (int i = 0; i < cols.length; i++) {
> +        for (int i = 0; i < _cols.length; i++) {
>              if (_vals[i] == null)
>                  continue;
>
> @@ -769,7 +775,7 @@
>                  buf.append(", ");
>                  vals.append(", ");
>              }
> -            buf.append(cols[i]);
> +            buf.append(_cols[i]);
>              if (_types[i] == RAW)
>                  vals.append(_vals[i]);
>              else
> @@ -796,10 +802,9 @@
>       * Appends the where clause onto the given sql buffer.
>       */
>      private void appendWhere(StringBuffer buf) {
> -        Column[] cols = getTable().getColumns();
>          boolean hasWhere = false;
> -        for (int i = 0; i < cols.length; i++) {
> -            if (_vals[getWhereIndex(cols[i])] == null)
> +        for (int i = 0; i < _cols.length; i++) {
> +            if (_vals[getWhereIndex(_cols[i])] == null)
>                  continue;
>
>              if (!hasWhere)
> @@ -809,12 +814,12 @@
>
>              // sqlserver seems to have problems using null parameters
in
> the
>              // where clause
> -            if (_vals[getWhereIndex(cols[i])] == NULL)
> -                buf.append(cols[i]).append(" IS NULL");
> +            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]);
> +                buf.append(_cols[i]).append(" = ").append(_vals[i]);
>              else
> -                buf.append(cols[i]).append(" = ?");
> +                buf.append(_cols[i]).append(" = ?");
>              hasWhere = true;
>          }
>      }
> @@ -841,14 +846,13 @@
>      public void flush(PreparedStatement stmnt, int idx, DBDictionary
> dict,
>          JDBCStore store)
>          throws SQLException {
> -        Column[] cols = getTable().getColumns();
>
>          // this simple method works because the SQL is always
prepared
>          // based on the indexing of the columns in the table object
--
> the
>          // same ordering we use when storing values and meta types.
skip
>          // updates when setting params for DELETEs; the updates are
just
> there
>          // to let us eval fk constraints
> -        int i = (getAction() == ACTION_DELETE) ? cols.length : 0;
> +        int i = (getAction() == ACTION_DELETE) ? _cols.length: 0;
>          Column col;
>          Object val;
>          int half = _vals.length / 2;
> @@ -863,10 +867,10 @@
>
>              // if this is an update the vals array will be 2 x the
cols
>              // array length; it repeats for where values
> -            if (i < cols.length)
> -                col = cols[i];
> +            if (i < _cols.length)
> +                col = _cols[i];
>              else
> -                col = cols[i - cols.length];
> +                col = _cols[i - _cols.length];
>
>              val = _vals[i];
>              if (val == NULL)
> @@ -890,14 +894,14 @@
>       * The array value array index for the given column's value.
>       */
>      private int getWhereIndex(Column col) {
> -        return col.getIndex() + getTable().getColumns().length;
> +        return col.getIndex() + _cols.length;
>      }
>
>      /**
>       * Performs a proper deep clone.
>       */
>      public Object clone() {
> -        RowImpl clone = newInstance(getTable(), getAction());
> +        RowImpl clone = newInstance(getColumns(), getAction());
>          copyInto(clone, false);
>          return clone;
>      }
> @@ -905,8 +909,8 @@
>      /**
>       * Return a new row.
>       */
> -    protected RowImpl newInstance(Table table, int action) {
> -        return new RowImpl(table, action);
> +    protected RowImpl newInstance(Column[] cols, int action) {
> +        return new RowImpl(cols, action);
>      }
>
>      /**
> @@ -939,4 +943,3 @@
>              row.setValid(true);
>      }
> }
> -
>
> Modified:
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/sql/SecondaryRow.java
> URL:
>
http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/ma
in/java/org/apache/openjpa/jdbc/sql/SecondaryRow.java?view=diff&rev=5094
73&r1=509472&r2=509473
>
>
========================================================================
======
> ---
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/sql/SecondaryRow.java
> (original)
> +++
>
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jd
bc/sql/SecondaryRow.java
> Tue Feb 20 00:59:10 2007
> @@ -43,7 +43,11 @@
>       * Constructor; supply table and action.
>       */
>      public SecondaryRow(Table table, int action) {
> -        super(table, action);
> +        this(table.getColumns(), action);
> +    }
> +
> +    protected SecondaryRow(Column[] cols, int action) {
> +        super(cols, action);
>      }
>
>      public void setForeignKey(ForeignKey fk, OpenJPAStateManager sm)
> @@ -161,8 +165,8 @@
>          return super.generateSQL(dict);
>      }
>
> -    protected RowImpl newInstance(Table table, int action) {
> -        return new SecondaryRow(table, action);
> +    protected RowImpl newInstance(Column[] cols, int action) {
> +        return new SecondaryRow(cols, action);
>      }
>
>      public void copyInto(RowImpl row, boolean whereOnly) {
>
>
>
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

Mime
View raw message