DAS.applyChanges() does not initialize database connection if needed --------------------------------------------------------------------
Key: TUSCANY-1434 URL: https://issues.apache.org/jira/browse/TUSCANY-1434 Project: Tuscany Issue Type: Bug Components: Java DAS RDB Affects Versions: Java-DAS-beta1 Reporter: Ron Gavlin I am attempting to use das.applyChanges() to insert a row into the CUSTOMER table. My augmented "basicCustomerMappingWithCUD2.xml" file includes a "ConnectionInfo" element with a "datasource" attribute specified. Note below that I am using static SDO without invoking the standard priming das.getCommand("command").executeQuery() before invoking das.applyChanges(). When I execute the following code snippet, I receive an error in das.applyChanges() that there is no database connection currently open. DAS das = DAS.FACTORY.createDAS(getConfig("basicCustomerMappingWithCUD2.xml")); DataGraph dg = SDOUtil.createDataGraph(); dg.getChangeSummary().beginLogging(); dg.createRootObject(TypeHelper.INSTANCE.getType(Customers.class)); Customers customers = (Customers) dg.getRootObject(); Customer customer = CustomerFactory.INSTANCE.createCustomer(); customer.setID(9999); customer.setLASTNAME("Jones"); customers.getCustomer().add(customer); // FIXME the following line is required to workaround this DAS bug // whereby no connection exists w/out a priming getCommand().executeQuery() // Note that the following line should be removed in this test code after the patch for this bug is applied ((DASImpl) das).getConnection(); // end of FIXME das.applyChanges((DataObject) customers); The proposed patch for this bug is as follows: org.apache.tuscany.das.rdb.impl.DASImpl.class Change line 114 FROM Line 107 /* * (non-Javadoc) * * @see org.apache.tuscany.das.rdb.CommandGroup#getApplyChangesCommand() */ public ApplyChangesCommandImpl getApplyChangesCommand() { ApplyChangesCommandImpl cmd = new ApplyChangesCommandImpl(configWrapper, connection); // Line 114 return cmd; } TO Line 107 /* * (non-Javadoc) * * @see org.apache.tuscany.das.rdb.CommandGroup#getApplyChangesCommand() */ public ApplyChangesCommandImpl getApplyChangesCommand() { ApplyChangesCommandImpl cmd = new ApplyChangesCommandImpl(configWrapper, getConnection()); //Line 114 return cmd; } FYI, the customer.xsd for this test was augmented to include the "Customers" complex type as follows: <xsd:complexType name="Customers"> <xsd:sequence> <xsd:element name="customer" type="Customer" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType> Let me know if you have questions. - Ron -- 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]