Auto Gen keys not getting updated in generated pojos
----------------------------------------------------

                 Key: TUSCANY-1807
                 URL: https://issues.apache.org/jira/browse/TUSCANY-1807
             Project: Tuscany
          Issue Type: Bug
          Components: Java DAS RDB
    Affects Versions: Java-DAS-beta1, Java-DAS-Next
         Environment: DB2 UDB ISeries V5R4
            Reporter: Nick Duncan


Using generated key column as defined in config.  If i use a dynamic data 
object that is not associated with any SDO type, then the auto generated key 
correctly gets set on the data object after applyChanges.  However, if I 
specify a type in the config xml with dataObjectModel being set, and with type 
and property being set, the associated field in my generated pojo does not get 
updated.  I have confirmed this in the latest release as well as most recent 
SNAPSHOT code.   

Below are code examples:


---The below config works-----
 <Config 
xsi:noNamespaceSchemaLocation="http:///org.apache.tuscany.das.rdb/config.xsd"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";> 

        <!--Uncomment below for db2 test-->
        <ConnectionInfo>
                <ConnectionProperties
                        driverClass="com.ibm.as400.access.AS400JDBCDriver"
                        databaseURL="jdbc:as400://-------------"
                        loginTimeout="600000"
                        userName="dunk"
                        password="***"/>
        </ConnectionInfo>

                        
    <Command SQL="select * from duncann.t_test" kind="Select" name ="AllAutos">
        <ResultDescriptor columnName="ID" tableName="t_test"   
columnType="commonj.sdo.Int"/>
        <ResultDescriptor columnName="NAME" tableName="t_test" 
columnType="commonj.sdo.String"/>
    </Command>

    <Table tableName="t_test" schemaName="duncann">
        <Column columnName="ID" primaryKey="true" generated="true" />
        <Column columnName="NAME" />
    </Table>
</Config>


--This config does not work in the sense that auto generated key does not get 
set after applyChanges ---
 <Config 
xsi:noNamespaceSchemaLocation="http:///org.apache.tuscany.das.rdb/config.xsd"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        dataObjectModel="autotest.xsd" > 

        
        <!--Uncomment below for db2 test-->
        <ConnectionInfo>
                <ConnectionProperties
                        driverClass="com.ibm.as400.access.AS400JDBCDriver"
                        databaseURL="jdbc:as400://-----"
                        loginTimeout="600000"
                        userName="dunk"
                        password="***"/>
        </ConnectionInfo>
        
        <Command name="AllAutos" SQL="select * from duncann.t_test" 
kind="Select">
        <ResultDescriptor columnName="ID" tableName="t_test"   
columnType="commonj.sdo.Int"/>
        <ResultDescriptor columnName="NAME" tableName="t_test" 
columnType="commonj.sdo.String"/>
    </Command>

    <Table tableName="t_test" typeName="AutoType" schemaName="duncann">
        <Column columnName="ID" primaryKey="true" generated="true" 
propertyName="id"/>
        <Column columnName="NAME" propertyName="name"/>
    </Table> 
</Config>



----Below is code snippet that shows this working with dynamic data object ---
                HelperContext context = HelperProvider.getDefaultContext();
                String fileName = 
"C:\\Rad7\\sdo2\\TuscanyDASTest\\configs\\TestConfig.xml";
                    Config config = ConfigUtil.loadConfig(new 
FileInputStream(fileName));
                    
                    DAS das = DAS.FACTORY.createDAS(config);

                DataObject root = das.getCommand("AllAutos").executeQuery();
                
                DataObject dao = (DataObject) root.createDataObject("t_test");
                dao.set("NAME","HjkjO");

                das.applyChanges(root);
                
                System.out.println(dao.get("ID"));

--------System outputs:  136



-----------Below snippet  shows what happens when using pojo to represent data 
object
                HelperContext context = HelperProvider.getDefaultContext();
                String fileName = 
"C:\\Rad7\\sdo2\\TuscanyDASTest\\configs\\TestConfig.xml";

                    
DASTestNick.loadTypesFromXMLSchemaFile(context,"C:/Rad7/sdo2/TuscanyDASTest/schemas/autotest.xsd");
                    
                    Config config = ConfigUtil.loadConfig(new 
FileInputStream(fileName));
                    
                    //now let's get an AutoTest (that refers to a table with 
auto increment)
                    GeneratedFactoryImpl gfi = (GeneratedFactoryImpl) 
GeneratedFactoryImpl.INSTANCE;
                    GeneratedFactoryImpl.INSTANCE.register(context);

                    DAS das = DAS.FACTORY.createDAS(config);
                    
                
                DataObject root = das.getCommand("AllAutos").executeQuery();
                
                AutoTypeImpl at = (AutoTypeImpl) 
root.createDataObject("AutoType");
                at.setName("sdfs");

                das.applyChanges(root);
                
                System.out.println(at.getId());

System Outputs: 0

The database gets correctly updated in both instances.  
Here is  my autotest.xsd for completeness:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:this="autotest.xsd" targetNamespace="autotest.xsd" 
xmlns:sdo="commonj.sdo"  xmlns:xsd="http://www.w3.org/2001/XMLSchema"; >
         <xsd:element name="AutoType">
                <xsd:complexType>
                        <xsd:sequence>
                                <xsd:element name="id" nillable="false" 
type="xsd:int"/>
                                <xsd:element name="name" type="xsd:string"/>
                        </xsd:sequence>
                </xsd:complexType>
        </xsd:element>
</xsd:schema>




-- 
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