[ 
https://issues.apache.org/jira/browse/TUSCANY-1815?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12530917
 ] 

Amita Vadhavkar commented on TUSCANY-1815:
------------------------------------------

In JUnit tests -
GeneratedId.testInsert4 - shows that when generated is true, setInt("ID", 999) 
is ignored.

Thus, DAS ignores setInt() when generated=true. To turn this off, you can 
remove this from the 
config. Also make sure that the table is created with no "GENERATED ALWAYS AS 
IDENTITY" clause. 
and then do createDataObject().

There is no direct "saveOrUpdate" supported. Also, when generated=true, there 
is no control on ID.
(i.e. the next ID generated will be decided/generated by DBMS). 


For "saveOrUpdate" case, (switch off generated feature), you will need to do a 
select for ID=100 
and see if there is DO. If it is there, use it to modify values and if it is 
not there do createDataObject() 
(with specifying the setInt(ID, 100))

see 
http://incubator.apache.org/tuscany/das-java-faq.html#DASJava-FAQ-RDBDASsupportforgeneratedkeys
http://incubator.apache.org/tuscany/workingwithgenerateddatabasekeys.html
http://incubator.apache.org/tuscany/configurable-database-generated-keys-support.html
for details of generated keys support.


> das.applyChanges will always do insert instead of update if createDataObject 
> was used
> -------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-1815
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1815
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java DAS RDB
>    Affects Versions: Java-DAS-beta1, Java-DAS-Next
>         Environment: DB2 Iseries
>            Reporter: Nick Duncan
>
> If I do something like: 
> -------------------------------
>               DataObject root = das.getCommand("AllAutos").executeQuery();
>               
>               DataObject dao = root.createDataObject("t_test");
>               dao.set("NAME", "NICK");
>               dao.set("ID", 100);
>               
>               das.applyChanges(root);
> -------------------------------------
> There is already a row in the table with primary key 100.  ID is defined in 
> the config xml as being the primary key,  it ignores that ID was set and does 
> an insert statement.  ID is also defined as an auto generated column.
> Basically I was expecting something like Hibernate's savorOrUpdate...   Maybe 
> if the field that represents primary key  is shown to have been changed in 
> the changeSummary, then  DAS will figure out what statement to generate.  
> Where I'm seeing this being a problem is if we get a dataobject that 
> represents a row in the database, and then send it off to a service, we get 
> back another object that has been updated, but since it is a different object 
> then the DAS will think it should do an update?  Merge doesn't  seem to  
> alleviate this problem either.  Please let me know if I am way off base here. 
>  Thanks

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to