Sorry. Problem solved:
ISqlMapper sqlMapper = Mapper.Instance();
sqlMapper.BeginTransaction();
--- All the inserts through direct ibatis calls, not Class.Insert()
-- In case all OK
sqlMapper.CommitTransaction(true);
-- else
sqlMapper.RollBackTransaction(true);
Sorry :-|
2008/6/24 Juan Pablo Araya <[EMAIL PROTECTED]>:
> Hi all.
>
> We have about 5 classess, each one of them mapped through iBatis.
> There exists relations between classess/tables, so we first insert one
> record, then the other based on the id of the recently created, an so.
> Example:
>
> Area --> Role --> Permissions
>
> First, we insert area, then the role relating the area id, and then
> the permissions related through the role id.
>
> We want some like the following:
>
> -Begin insert
> try {
> Area area = new Area()
> area.Insert()
>
> Role role = new Role()
> role.area_Id = area.id
> Role.insert()
>
> Permissions perm = new Permissions()
> perm.Role_id = role.id
> Permissions.Insert()
> }
> catch(Exception) {
> RollBack the entire inserts()
> }
>
> We are using state machine workflows and a data model for the
> presentation layer (one table shows the workflow state, in case all
> inserts and modifications to the state machine worked perfectly), so
> when we trigger an action to a workflow, it makes the inserts/updates,
> changes it's state and then persist. If iBatis throw an exception, the
> table that shows the workflow state finishes inconsistently because
> the iBatis exception doesn't permits the workflow to change the status
> and then persist.
>
> Anyone knows who can I do a rollback of a set of inserts/updates?
>
> Thanks and sorry for my poor english!
>