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

Nick Duncan commented on TUSCANY-1815:
--------------------------------------

Thank you for the thorough responses.  I wasn't trying to setID so much as just 
use the ID setter to show which data object I wanted to update.

If GraphMerger would play nicer with dataObjects created from a factory and 
then merged with a root created from a DAS, then I don't think there would be 
an issue.  

Consider this scenario:

                    DataObject root = das.getCommand("AllAutos").executeQuery();
                    
                    AutoTypeImpl at= (AutoTypeImpl) 
GeneratedFactoryImpl.INSTANCE.createAutoType();
                    at.setName("nick");
                    at.setId(100);
                    
                    DataObject root1 = at.getRootObject();
                    
                   GraphMerger gm = new GraphMerger();
                   gm.addPrimaryKey("AutoType.id");
                   root = gm.merge(root, root1);

                    das.applyChanges(root);


 --Except that will blow up with 

java.lang.ClassCastException: java.lang.Integer incompatible with java.util.List
        at 
org.apache.tuscany.sdo.impl.DataObjectImpl.getList(DataObjectImpl.java:375)

I do realize that it works if both root and root1 were derived from a DAS, but 
that seems to be a limitation

-----------
What I want to do is have a root object that holds onto data objects, 
originally retrieved from a command.  I then want the abiliity to get data 
objects from any source ( a service, a factory, etc...) and then merge them, 
and then DAS will either do updates saves or deletes accordingly.   As long as 
the the data objects are of the same type I would think that should work.  

If I have data objects of the correct type but were not derived from a das, 
then I don't see any *clean* way of doing what I want.  Thanks.

> 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