Hello, I am using static data object, in my configuration file:
<Table tableName="FM_TEST_CUSTOMER" typeName="Customer">
<Column columnName="USER_ID" primaryKey="true" />
</Table>
<Table tableName="FM_TEST_ORDER" typeName="Order">
<Column columnName="ORDER_ID" primaryKey="true" />
</Table>
<Relationship name="ORDERS" primaryKeyTable="FM_TEST_CUSTOMER"
foreignKeyTable="FM_TEST_ORDER" many="true">
<KeyPair primaryKeyColumn="USER_ID" foreignKeyColumn="USER_ID" />
</Relationship>
And I use the static DataObject codes which generated from tuscany
Tool,so I have Customer static DataObject
and Order static DataObject,and Customer has a list property ORDERS.
however, when I add a "Order" DataObject:
SDOUtil.registerStaticTypes(CustomerFactory.class);
DAS das = DAS.FACTORY.createDAS(test.getConfig("FM_TEST_CUSTOMER.xml"),
getConnection());
Command selectCommand = das.getCommand("all customers with order");
DataObject root = selectCommand.executeQuery();
Customer customer = (Customer)root.getDataObject("Customer[1]");
Order order = (Order)root.createDataObject("Order");
order.setUSER_ID(new BigDecimal(2));
order.setGOOD_ID(new BigDecimal(3));
customer.getORDERS().add(order);
das.applyChanges(root);
It will throws an Exception:
Exception in thread "main" java.lang.RuntimeException:
java.sql.SQLException:invalidation column type
I tracked the source of tuscany, and find it produced a sql:
update FM_TEST_CUSTOMER set ORDERS= ? where SERVICE_ID = ?