Hi all, I am using static data object, in my configuration file, I use
propertyName attribute to map Table column to DataObject class's property,
<Table tableName="CCP_USER" typeName="User">
<Column columnName="USER_ID" propertyName="userId"
primaryKey="true"/>
<Column columnName="PASSWORD" propertyName="password"/>
<Column columnName="NAME" propertyName="name"/>
<Column columnName="AVAILABLE"
propertyName="available"/>
</Table>
however, when I use following code to add a new object to database, it
fails because the error sql produced by tuscany das.
User user=(User)UserFactory.INSTANCE.createUser();
user.setUserId("aaabbiiiiiiiiibc");
user.setPassword("898989");
user.setName("wo");
user.setAvailable("1");
Connection conn=dataSource.getConnection();
conn.setAutoCommit(false);
DAS das=DAS.FACTORY.createDAS(new
ClassPathResource(schemaConfig).getInputStream(),conn);
Command command=das.getCommand(commandName);
DataObject root=command.executeQuery();
if(logger.isDebugEnabled()) logger.debug("dataobject to be
insert:"+object.toString());
root.getList(object.getType().getName()).add(object);
das.applyChanges(root);
tuscany das produces a sql: insert into ccp_user(userid, password, name,
available) values(?,?,?,?) , it is obviously that userid is the property of
data object class but not the column of the table.
Is it a bug?
I read the source code of InsertGenerator class, it just :
attributes.add(attr.getName()); to get the dataobject property,
after I modify it to attributes.add(config.getColumnByPropertyName(t,
attr.getName()).getColumnName()); to get the table column compose the insert
sql, it works correctly.