You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Luciano Resende <lu...@gmail.com> on 2006/12/20 01:15:05 UTC

ApplyChnages fails when added DO does not include a modified property, was [jira] Created: (TUSCANY-1007)

Hi Kevin

   My understanding is that we do not generate commands that include the ID
when it is a generated primary key of a table, also, if you want to force a
insert passing all fields you will loose any default column value especified
during table creation. I think what you really want is to create a empty
record with the appropriae primary key on the table, and I'm trying to do
some reserch if this is possible or not. If anyone have any ideas on how to
create a SQL command to create an empty record without specifying any values
to the columns (e.g NULL) please let us know.


-- 
Luciano Resende
http://people.apache.org/~lresende


---------- Forwarded message ----------
From: Kevin Williams (JIRA) <tu...@ws.apache.org>
Date: Dec 19, 2006 11:17 AM
Subject: [jira] Created: (TUSCANY-1007) ApplyChnages fails when added DO
does not include a modified property
To: tuscany-dev@ws.apache.org

ApplyChnages fails when added DO does not include a modified property
---------------------------------------------------------------------

                 Key: TUSCANY-1007
                 URL: http://issues.apache.org/jira/browse/TUSCANY-1007
             Project: Tuscany
          Issue Type: Bug
            Reporter: Kevin Williams


Looks like the generated insert is invalid when the change history for an
added DO does not include a modified property.  I think the correct behavior
should be to generate an ID-only INSERT.  An alternative would be to
generate an INSERT that initializes all columns  ... i'd be interested in
hearing arguments to justify the latter.

This test:

    /das/src/test/java/org/apache/tuscany/das/rdb/test/CrudWithChangeHistory.testReadInsertApply()

demonstrates the problem.  I have temporarily commented it out.

Here is the stack trace:

java.lang.RuntimeException: SQL Exception: Column 'ID'  cannot accept a NULL
value.
        at org.apache.tuscany.das.rdb.impl.InsertCommandImpl.execute(
InsertCommandImpl.java:47)
        at org.apache.tuscany.das.rdb.impl.ChangeOperation.execute(
ChangeOperation.java:73)
        at org.apache.tuscany.das.rdb.impl.Changes.execute(Changes.java:57)
        at org.apache.tuscany.das.rdb.impl.ApplyChangesCommandImpl.execute(
ApplyChangesCommandImpl.java:69)
        at org.apache.tuscany.das.rdb.impl.DASImpl.applyChanges(DASImpl.java
:244)
        at
org.apache.tuscany.das.rdb.test.CrudWithChangeHistory.testReadInsertApply(
CrudWithChangeHistory.java:289)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:64)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:615)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.extensions.TestSetup.run(TestSetup.java:23)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
RemoteTestRunner.java:478)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(
RemoteTestRunner.java:344)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
RemoteTestRunner.java:196)
Caused by: SQL Exception: Column 'ID'  cannot accept a NULL value.
        at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown
Source)
        at
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown
Source)
        at
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown
Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown
Source)
        at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown
Source)
        at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown
Source)
        at
org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown
Source)
        at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unknown
Source)
        at org.apache.tuscany.das.rdb.impl.Statement.executeUpdate(
Statement.java:173)
        at org.apache.tuscany.das.rdb.impl.Statement.executeUpdate(
Statement.java:133)
        at org.apache.tuscany.das.rdb.impl.InsertCommandImpl.execute(
InsertCommandImpl.java:44)
        ... 28 more



--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



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

Re: ApplyChnages fails when added DO does not include a modified property, was [jira] Created: (TUSCANY-1007)

Posted by Luciano Resende <lu...@gmail.com>.
I asked Daniel, from Derby, and i got the answer that this should work in
derby, with the following syntax :

INSERT INTO T(colname) VALUES DEFAULT

Not sure about DB2...

-- 
Luciano Resende
http://people.apache.org/~lresende

On 12/21/06, Brent Daniel <br...@gmail.com> wrote:
>
> At the least, DB2 and Derby do not support this. Thus, the current
> approach is to generate a full update rather than a partial update
> (pulling each field from the DataObject -- always null unless the
> property is a primitive.)
>
> Brent
>
> On 12/20/06, Luciano Resende <lu...@gmail.com> wrote:
> > I tried this with MySQL and it worked, columns with no default values
> were
> > initialized as NULL.
> >
> > --
> > Luciano Resende
> > http://people.apache.org/~lresende
> >
> > On 12/19/06, Kevin Williams <ke...@qwest.net> wrote:
> > >
> > > Luciano,
> > >
> > > I think you are right.  The best behavior may be to generate an INSERT
> > > statement that specifies no column values at all.  Some databases will
> > > allow insert statements like this:
> > >
> > >     INSERT INTO tableName () VALUES ()
> > >
> > > But, I am not certain this is standard; we need to check.  DB errors
> are
> > > likely if default values have not been specified for all columns.
> > > --
> > > Kevin
> > >
> > >
> > > Luciano Resende wrote:
> > >
> > > > Hi Kevin
> > > >
> > > >   My understanding is that we do not generate commands that include
> > > > the ID
> > > > when it is a generated primary key of a table, also, if you want to
> > > > force a
> > > > insert passing all fields you will loose any default column value
> > > > especified
> > > > during table creation. I think what you really want is to create a
> empty
> > > > record with the appropriae primary key on the table, and I'm trying
> to
> > > do
> > > > some reserch if this is possible or not. If anyone have any ideas on
> > > > how to
> > > > create a SQL command to create an empty record without specifying
> any
> > > > values
> > > > to the columns (e.g NULL) please let us know.
> > > >
> > > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: tuscany-dev-help@ws.apache.org
> > >
> > >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>

Re: ApplyChnages fails when added DO does not include a modified property, was [jira] Created: (TUSCANY-1007)

Posted by Brent Daniel <br...@gmail.com>.
At the least, DB2 and Derby do not support this. Thus, the current
approach is to generate a full update rather than a partial update
(pulling each field from the DataObject -- always null unless the
property is a primitive.)

Brent

On 12/20/06, Luciano Resende <lu...@gmail.com> wrote:
> I tried this with MySQL and it worked, columns with no default values were
> initialized as NULL.
>
> --
> Luciano Resende
> http://people.apache.org/~lresende
>
> On 12/19/06, Kevin Williams <ke...@qwest.net> wrote:
> >
> > Luciano,
> >
> > I think you are right.  The best behavior may be to generate an INSERT
> > statement that specifies no column values at all.  Some databases will
> > allow insert statements like this:
> >
> >     INSERT INTO tableName () VALUES ()
> >
> > But, I am not certain this is standard; we need to check.  DB errors are
> > likely if default values have not been specified for all columns.
> > --
> > Kevin
> >
> >
> > Luciano Resende wrote:
> >
> > > Hi Kevin
> > >
> > >   My understanding is that we do not generate commands that include
> > > the ID
> > > when it is a generated primary key of a table, also, if you want to
> > > force a
> > > insert passing all fields you will loose any default column value
> > > especified
> > > during table creation. I think what you really want is to create a empty
> > > record with the appropriae primary key on the table, and I'm trying to
> > do
> > > some reserch if this is possible or not. If anyone have any ideas on
> > > how to
> > > create a SQL command to create an empty record without specifying any
> > > values
> > > to the columns (e.g NULL) please let us know.
> > >
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-dev-help@ws.apache.org
> >
> >
>
>

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


Re: ApplyChnages fails when added DO does not include a modified property, was [jira] Created: (TUSCANY-1007)

Posted by Luciano Resende <lu...@gmail.com>.
I tried this with MySQL and it worked, columns with no default values were
initialized as NULL.

-- 
Luciano Resende
http://people.apache.org/~lresende

On 12/19/06, Kevin Williams <ke...@qwest.net> wrote:
>
> Luciano,
>
> I think you are right.  The best behavior may be to generate an INSERT
> statement that specifies no column values at all.  Some databases will
> allow insert statements like this:
>
>     INSERT INTO tableName () VALUES ()
>
> But, I am not certain this is standard; we need to check.  DB errors are
> likely if default values have not been specified for all columns.
> --
> Kevin
>
>
> Luciano Resende wrote:
>
> > Hi Kevin
> >
> >   My understanding is that we do not generate commands that include
> > the ID
> > when it is a generated primary key of a table, also, if you want to
> > force a
> > insert passing all fields you will loose any default column value
> > especified
> > during table creation. I think what you really want is to create a empty
> > record with the appropriae primary key on the table, and I'm trying to
> do
> > some reserch if this is possible or not. If anyone have any ideas on
> > how to
> > create a SQL command to create an empty record without specifying any
> > values
> > to the columns (e.g NULL) please let us know.
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>

Re: ApplyChnages fails when added DO does not include a modified property, was [jira] Created: (TUSCANY-1007)

Posted by Kevin Williams <ke...@qwest.net>.
Luciano,

I think you are right.  The best behavior may be to generate an INSERT 
statement that specifies no column values at all.  Some databases will 
allow insert statements like this:

    INSERT INTO tableName () VALUES ()

But, I am not certain this is standard; we need to check.  DB errors are 
likely if default values have not been specified for all columns.
--
Kevin


Luciano Resende wrote:

> Hi Kevin
>
>   My understanding is that we do not generate commands that include 
> the ID
> when it is a generated primary key of a table, also, if you want to 
> force a
> insert passing all fields you will loose any default column value 
> especified
> during table creation. I think what you really want is to create a empty
> record with the appropriae primary key on the table, and I'm trying to do
> some reserch if this is possible or not. If anyone have any ideas on 
> how to
> create a SQL command to create an empty record without specifying any 
> values
> to the columns (e.g NULL) please let us know.
>
>



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