You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "garpinc (JIRA)" <ji...@apache.org> on 2012/09/20 00:54:07 UTC
[jira] [Created] (OPENJPA-2263) Update statements should not update
the primary key of database unless the primary key has in fact changed
garpinc created OPENJPA-2263:
--------------------------------
Summary: Update statements should not update the primary key of database unless the primary key has in fact changed
Key: OPENJPA-2263
URL: https://issues.apache.org/jira/browse/OPENJPA-2263
Project: OpenJPA
Issue Type: Bug
Components: jdbc
Affects Versions: 2.2.0
Reporter: garpinc
I have encountered a situation while creating an openjpa dictionary for teradata. It seems teradata does not like it when the primary key is updated.
i.e: update tablex set pk=1 where pk=1;
Following the code it seems RowImpl.java contains a method getUpdateSQL which uses the dictionary to various things but it doesn't allow the dictionary to change the statement itself.
The specific functionality I need here is to only update the pk if the pk has changed or maybe an option not to update the pk at all.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (OPENJPA-2263) Update statements should not
update the primary key of database unless the primary key has in fact
changed
Posted by "garpinc (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-2263?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
garpinc resolved OPENJPA-2263.
------------------------------
Resolution: Not A Problem
Fix Version/s: 2.2.0
In creating the test case I found out that OpenJPAPersistence.cast(em).dirty(wrapper, fieldName) was called on the primary key field.
I guess it's speculative whether a call like should trigger behavior like this if the field hasn't in fact changed so i've decided it's not a problem and i just did not make the primary key as dirty.
> Update statements should not update the primary key of database unless the primary key has in fact changed
> ----------------------------------------------------------------------------------------------------------
>
> Key: OPENJPA-2263
> URL: https://issues.apache.org/jira/browse/OPENJPA-2263
> Project: OpenJPA
> Issue Type: Bug
> Components: jdbc
> Affects Versions: 2.2.0
> Reporter: garpinc
> Fix For: 2.2.0
>
>
> I have encountered a situation while creating an openjpa dictionary for teradata. It seems teradata does not like it when the primary key is updated.
> i.e: update tablex set pk=1 where pk=1;
> Following the code it seems RowImpl.java contains a method getUpdateSQL which uses the dictionary to various things but it doesn't allow the dictionary to change the statement itself.
> The specific functionality I need here is to only update the pk if the pk has changed or maybe an option not to update the pk at all.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (OPENJPA-2263) Update statements should not
update the primary key of database unless the primary key has in fact
changed
Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-2263?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13459875#comment-13459875 ]
Rick Curtis commented on OPENJPA-2263:
--------------------------------------
Can you post a testcase which exhibits this behavior that you're referring to?
> Update statements should not update the primary key of database unless the primary key has in fact changed
> ----------------------------------------------------------------------------------------------------------
>
> Key: OPENJPA-2263
> URL: https://issues.apache.org/jira/browse/OPENJPA-2263
> Project: OpenJPA
> Issue Type: Bug
> Components: jdbc
> Affects Versions: 2.2.0
> Reporter: garpinc
>
> I have encountered a situation while creating an openjpa dictionary for teradata. It seems teradata does not like it when the primary key is updated.
> i.e: update tablex set pk=1 where pk=1;
> Following the code it seems RowImpl.java contains a method getUpdateSQL which uses the dictionary to various things but it doesn't allow the dictionary to change the statement itself.
> The specific functionality I need here is to only update the pk if the pk has changed or maybe an option not to update the pk at all.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (OPENJPA-2263) Update statements should not update
the primary key of database unless the primary key has in fact changed
Posted by "garpinc (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-2263?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
garpinc updated OPENJPA-2263:
-----------------------------
Attachment: testselect0.zip
test case to try is the testSelect0 one. When run in the console you will see the select in the trace right after the last alter table
> Update statements should not update the primary key of database unless the primary key has in fact changed
> ----------------------------------------------------------------------------------------------------------
>
> Key: OPENJPA-2263
> URL: https://issues.apache.org/jira/browse/OPENJPA-2263
> Project: OpenJPA
> Issue Type: Bug
> Components: jdbc
> Affects Versions: 2.2.0
> Reporter: garpinc
> Fix For: 2.2.0
>
> Attachments: testselect0.zip
>
>
> I have encountered a situation while creating an openjpa dictionary for teradata. It seems teradata does not like it when the primary key is updated.
> i.e: update tablex set pk=1 where pk=1;
> Following the code it seems RowImpl.java contains a method getUpdateSQL which uses the dictionary to various things but it doesn't allow the dictionary to change the statement itself.
> The specific functionality I need here is to only update the pk if the pk has changed or maybe an option not to update the pk at all.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Comment Edited] (OPENJPA-2263) Update statements should not
update the primary key of database unless the primary key has in fact
changed
Posted by "garpinc (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-2263?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13459865#comment-13459865 ]
garpinc edited comment on OPENJPA-2263 at 9/21/12 6:20 AM:
-----------------------------------------------------------
To address temporarily I added the following lines to RowImpl. I think that perhaps this should be done at another level and at a minimum there should be a DBDictionary option to turn on or off this functionality instead of the hardcoded "Teradata". Also an improvement would be that Dictionary always has a final chance to modify the final statement.
/* new lines on line 735 of RowImpl.java */
if (_cols[i].isPrimaryKey() && dict.platform.equals("Teradata")) {
_vals[i] = null;
}
/* end of new lines */
if (_vals[i] == null)
continue;
was (Author: garpinc):
To address temporarily I added the following lines to RowImpl. I think that perhaps this should be done at another level and at a minimum there should be a DBDictionary option to turn on or off this functionality instead of the hardcoded "Teradata". Also an improvement would be that Dictionary always has a final change to modify the final statement.
/* new lines on line 735 of RowImpl.java */
if (_cols[i].isPrimaryKey() && dict.platform.equals("Teradata")) {
_vals[i] = null;
}
/* end of new lines */
if (_vals[i] == null)
continue;
> Update statements should not update the primary key of database unless the primary key has in fact changed
> ----------------------------------------------------------------------------------------------------------
>
> Key: OPENJPA-2263
> URL: https://issues.apache.org/jira/browse/OPENJPA-2263
> Project: OpenJPA
> Issue Type: Bug
> Components: jdbc
> Affects Versions: 2.2.0
> Reporter: garpinc
>
> I have encountered a situation while creating an openjpa dictionary for teradata. It seems teradata does not like it when the primary key is updated.
> i.e: update tablex set pk=1 where pk=1;
> Following the code it seems RowImpl.java contains a method getUpdateSQL which uses the dictionary to various things but it doesn't allow the dictionary to change the statement itself.
> The specific functionality I need here is to only update the pk if the pk has changed or maybe an option not to update the pk at all.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Comment Edited] (OPENJPA-2263) Update statements should not
update the primary key of database unless the primary key has in fact
changed
Posted by "garpinc (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-2263?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13460519#comment-13460519 ]
garpinc edited comment on OPENJPA-2263 at 9/22/12 1:32 AM:
-----------------------------------------------------------
This contains the test case that illustrates that a dirty field will cause the pk to be updated although it hasn't changed.. Once again this is likely expected behavior but it did give me a bump in the road.. Test case in this is: TestCollectionValueMapper.testUpdatePk()
was (Author: garpinc):
test case to try is the testSelect0 one. When run in the console you will see the select in the trace right after the last alter table
> Update statements should not update the primary key of database unless the primary key has in fact changed
> ----------------------------------------------------------------------------------------------------------
>
> Key: OPENJPA-2263
> URL: https://issues.apache.org/jira/browse/OPENJPA-2263
> Project: OpenJPA
> Issue Type: Bug
> Components: jdbc
> Affects Versions: 2.2.0
> Reporter: garpinc
> Fix For: 2.2.0
>
> Attachments: testselect0.zip
>
>
> I have encountered a situation while creating an openjpa dictionary for teradata. It seems teradata does not like it when the primary key is updated.
> i.e: update tablex set pk=1 where pk=1;
> Following the code it seems RowImpl.java contains a method getUpdateSQL which uses the dictionary to various things but it doesn't allow the dictionary to change the statement itself.
> The specific functionality I need here is to only update the pk if the pk has changed or maybe an option not to update the pk at all.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (OPENJPA-2263) Update statements should not
update the primary key of database unless the primary key has in fact
changed
Posted by "garpinc (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-2263?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13459865#comment-13459865 ]
garpinc commented on OPENJPA-2263:
----------------------------------
To address temporarily I added the following lines to RowImpl. I think that perhaps this should be done at another level and at a minimum there should be a DBDictionary option to turn on or off this functionality instead of the hardcoded "Teradata". Also an improvement would be that Dictionary always has a final change to modify the final statement.
/* new lines on line 735 of RowImpl.java */
if (_cols[i].isPrimaryKey() && dict.platform.equals("Teradata")) {
_vals[i] = null;
}
/* end of new lines */
if (_vals[i] == null)
continue;
> Update statements should not update the primary key of database unless the primary key has in fact changed
> ----------------------------------------------------------------------------------------------------------
>
> Key: OPENJPA-2263
> URL: https://issues.apache.org/jira/browse/OPENJPA-2263
> Project: OpenJPA
> Issue Type: Bug
> Components: jdbc
> Affects Versions: 2.2.0
> Reporter: garpinc
>
> I have encountered a situation while creating an openjpa dictionary for teradata. It seems teradata does not like it when the primary key is updated.
> i.e: update tablex set pk=1 where pk=1;
> Following the code it seems RowImpl.java contains a method getUpdateSQL which uses the dictionary to various things but it doesn't allow the dictionary to change the statement itself.
> The specific functionality I need here is to only update the pk if the pk has changed or maybe an option not to update the pk at all.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira