вторник, 29 октября 2013 г.

Запись изменений VO в базу без commit

Для автоматической записи в БД всех изменений происходящих на уровне WLS
можно выставить  this.setAutoPostChanges(true); в объекте VOImpl.

ВАЖНО:
1. запись будет происходить только  в момент выполнения ExecuteQuery()
2. на измененных записях таблицы выставляется блокировка




What you may need to know about DBTransaction::postChanges()


// Get VewRowImpl someVewRowImpl from VO  
    someVewRowImpl.setAttribute( "SomeAttrib","New Value");  
    EntityImpl someEOImpl = someVewRowImpl.getEntity(0);  
    DBTransaction txn = getDBTransaction();  
    txn.validate();  
    txn.postChanges();  
    txn.removeTransactionPostListener(someEOImpl); 
 
    //The below two lines may cause your EO to skip 
    // beforeCommit() and afterCommit() call backs.
    //Normally you can skip the below two lines, 
    // use it if you need to clear the EO cache once data is posted to DB
    // This makes sense if you have millions of rows in an update and
    // and you want to get rid of the cached rows without any delay
    txn.removeTransactionListener(someEOImpl); 
    txn.clearEntityCache(null);



Комментариев нет:

Отправить комментарий