I created one table called "cart" with an auto-increment key on mysql, then
I defined this table on the config.xml as containing an auto-increment key.
Using SCO/DAS I create one tuple of the "cart" table, but no attribute is
set. I know DAS only update one attribute tuple only if it has been modified
and if no attribute is set the tuple should not be added in the database,
but it is implicit that at least one attribute will be set, in this case the
primary key, cause it is set as auto-increment key. Unfortunately the tuple
is not being added in the database : (. Should it be working this way?

Here is the code that tries to create a new cart tuple in the database:

public void newCart() {
       DAS das = DAS.FACTORY.createDAS
(getClass().getClassLoader().getResourceAsStream("ShoppingCartConfig.xml"),
getConnection());
       Command command = das.getCommand("all carts");
       DataObject allCarts = command.executeQuery();

       DataObject newCart = allCarts.createDataObject("CART");
       allCarts.getList("CART").add(newCart);
       das.applyChanges(allCarts);

   }


How the table "cart" is being declared in the mysql database:

CREATE TABLE CART (
 ID INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
 SUB_TOTAL DOUBLE,
 TAX DOUBLE,
 TOTAL DOUBLE,
 CONFIRMED INTEGER
);

ShoppingCartConfig.xml:

<?xml version="1.0" encoding="ASCII"?>
<Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd";>

   <Command name="all carts" SQL="SELECT * FROM CART" kind="Select"/>

   <Table tableName="CART">
       <Column columnName="ID" primaryKey="true" generated="true"/>
   </Table>

</Config>

Reply via email to