update rowId wnels2  2009-04-30 11:47
Status: Closed
 
For the method Table.update(User user, TableInfo table, K fieldsIn, Object rowId, Object rowVersion),
how does the application determine which column is used for rowId; the primary key?
I didn't notice any annotation in the schema.xml or in the table's model bean.

Thanks,
Bill
 
 
wnels2 responded:  2009-04-30 12:21
Okay, I think I found it. You can specify the PK in the xml but if it is not there it must have the optional rowid in your table?
Thanks,
Bill
 
adam responded:  2009-04-30 12:25
I believe if the PK isn't set explicitly in XML we'll pull it from the database meta data. This is generally how we handle it -- the XML is used primarily to override and augment the meta data.
 
wnels2 responded:  2009-05-01 10:21
Thanks Adam,
One more question please.
I want to put some Table.Insert/Update/Delete commands into a transaction. Can I do this? The only examples I can find use the JDBC connection with manually created SQL.

Thanks,
Bill
 
jeckels responded:  2009-05-01 11:24
Hi Bill,

Yes, you can use transactions with those methods on Table. The general pattern is:

tableInfo.getSchema().getScope().beginTransaction();
try
{
    // Do some calls to Table.insert(), etc

    tableInfo.getSchema().getScope().commitTransaction();
}
finally
{
    tableInfo.getSchema().getScope().closeConnection();
}

This will make sure that your connection is closed properly, and that your transaction rolls back if there were any exceptions.

Thanks,
Josh