Friday, January 22, 2016

Entity Lifecycle

Consider the following table:

CREATE TABLE validation(
  validation_id NUMBER PRIMARY KEY,
  string_column_nn VARCHAR2(50) NOT NULL,
  string_column_n VARCHAR2(50) NULL,
  number_column_nn NUMBER NOT NULL,
  number_column_n NUMBER NULL
);

INSERT INTO validation VALUES (1, 'STRING', NULL, 1, NULL );
INSERT INTO validation VALUES (2, 'STRING', NULL, 2, NULL );
COMMIT;

                                                                                                                                           

LOG OF AUTO POSTING 
(When attributes are updated manually on the UI, instead of calling setAttribute() in doDML)
                                                                                                                                           

LKAPOOR>> SETTER : i = 1, validation_id = 2, value = STRING431
LKAPOOR>> SETTER : i = 3, validation_id = 2, value = 22
LKAPOOR >> ENTERING ValidateEntity
LKAPOOR>> VALIDATION ID = 2
LKAPOOR >> EXITING ValidateEntity

<oracle.adf.model> <DCUtil> <findSpelObject> <[314] DCUtil, returning:oracle.jbo.uicli.binding.JUApplication, for AppModuleDataControl> 
<oracle.adf.model> <OracleSQLBuilderImpl> <setSavepoint> <[315] OracleSQLBuilder: SAVEPOINT 'BO_SP'

LKAPOOR >> ENTERING postChanges
LKAPOOR>> VALIDATION ID = 2

<oracle.adf.model> <OracleSQLBuilderImpl> <doEntitySelectForAltKey> <[316] OracleSQLBuilder Executing doEntitySelect on: VALIDATION (true)> 
<oracle.adf.model> <OracleSQLBuilderImpl> <buildSelectString> <[317] Built select: 'SELECT VALIDATION_ID, STRING_COLUMN_NN, STRING_COLUMN_N, NUMBER_COLUMN_NN, NUMBER_COLUMN_N FROM VALIDATION ValidationEO'> 
<oracle.adf.model> <OracleSQLBuilderImpl> <doEntitySelectForAltKey> <[318] Executing LOCK...SELECT VALIDATION_ID, STRING_COLUMN_NN, STRING_COLUMN_N, NUMBER_COLUMN_NN, NUMBER_COLUMN_N FROM VALIDATION ValidationEO WHERE VALIDATION_ID=:1 FOR UPDATE NOWAIT> 
<oracle.adf.model> <OracleSQLBuilderImpl> <bindWhereAttrValue> <[319] Where binding param 1: 2> 

LKAPOOR >> ENTERING doDML
LKAPOOR>> VALIDATION ID = 2

<oracle.adf.model> <OracleSQLBuilderImpl> <doEntityDML> <[320] OracleSQLBuilder Executing, Lock 2 DML on: VALIDATION (Update)> 
<oracle.adf.model> <OracleSQLBuilderImpl> <buildUpdateStatement> <[321] UPDATE buf ValidationEO>#u SQLStmtBufLen: 255, actual=97> 
<oracle.adf.model> <OracleSQLBuilderImpl> <doEntityDML> <[322] UPDATE VALIDATION ValidationEO SET STRING_COLUMN_NN=:1,NUMBER_COLUMN_NN=:2 WHERE VALIDATION_ID=:3
<oracle.adf.model> <OracleSQLBuilderImpl> <bindUpdateStatement> <[323] Update binding param 1: STRING431
<oracle.adf.model> <OracleSQLBuilderImpl> <bindUpdateStatement> <[324] Update binding param 2: 22
<oracle.adf.model> <OracleSQLBuilderImpl> <bindWhereAttrValue> <[325] Where binding param 3: 2

LKAPOOR >> EXITING doDML
LKAPOOR >> EXITING postChanges

<oracle.adf.model> <ViewObjectImpl> <afterCommit> <[326] ValidationVO1 notify COMMIT ... > 
<oracle.adf.model> <EntityCache> <closeStatement> <[327] EntityCache close prepared statement>

                                                                                                                                           

LOG OF PROGRAMMATIC POSTING 
(When SetAttribute() is called in doDML() explicitly to set an attribute value before commit )
                                                                                                                                           

LKAPOOR>> SETTER : i = 1, validation_id = 1, value = STRING3553332
LKAPOOR >> ENTERING ValidateEntity
LKAPOOR>> VALIDATION ID = 1
LKAPOOR >> EXITING ValidateEntity

<oracle.adf.model> <DCUtil> <findSpelObject> <[366] DCUtil, returning:oracle.jbo.uicli.binding.JUApplication, for AppModuleDataControl> 
<oracle.adf.model> <OracleSQLBuilderImpl> <setSavepoint> <[367] OracleSQLBuilder: SAVEPOINT 'BO_SP'> 

LKAPOOR >> ENTERING postChanges
LKAPOOR>> VALIDATION ID = 1

<oracle.adf.model> <OracleSQLBuilderImpl> <doEntitySelectForAltKey> <[368] OracleSQLBuilder Executing doEntitySelect on: VALIDATION (true)> 
<oracle.adf.model> <OracleSQLBuilderImpl> <buildSelectString> <[369] Built select: 'SELECT VALIDATION_ID, STRING_COLUMN_NN, STRING_COLUMN_N, NUMBER_COLUMN_NN, NUMBER_COLUMN_N FROM VALIDATION ValidationEO'> 
<oracle.adf.model> <OracleSQLBuilderImpl> <doEntitySelectForAltKey> <[370] Executing LOCK...SELECT VALIDATION_ID, STRING_COLUMN_NN, STRING_COLUMN_N, NUMBER_COLUMN_NN, NUMBER_COLUMN_N FROM VALIDATION ValidationEO WHERE VALIDATION_ID=:1 FOR UPDATE NOWAIT> 
<oracle.adf.model> <OracleSQLBuilderImpl> <bindWhereAttrValue> <[371] Where binding param 1: 1> 

LKAPOOR >> ENTERING doDML
LKAPOOR>> VALIDATION ID = 1

i = 4, validation_id = 1, value = 2
<oracle.adf.model> <JUCtrlValueBinding> <createAndNotifyDCE> <[372] Binding:NumberColumnN, DataChangeEvent UPDATEbeing raised for (first attributename in the event):NumberColumnN> 
<oracle.adf.model> <OracleSQLBuilderImpl> <doEntityDML> <[373] OracleSQLBuilder Executing, Lock 2 DML on: VALIDATION (Update)> 
<oracle.adf.model> <OracleSQLBuilderImpl> <buildUpdateStatement> <[374] UPDATE buf ValidationEO>#u SQLStmtBufLen: 255, actual=96> 
<oracle.adf.model> <OracleSQLBuilderImpl> <doEntityDML> <[375] UPDATE VALIDATION ValidationEO SET STRING_COLUMN_NN=:1,NUMBER_COLUMN_N=:2 WHERE VALIDATION_ID=:3
<oracle.adf.model> <OracleSQLBuilderImpl> <bindUpdateStatement> <[376] Update binding param 1: STRING3553332> 
<oracle.adf.model> <OracleSQLBuilderImpl> <bindUpdateStatement> <[377] Update binding param 2: 2> 
<oracle.adf.model> <OracleSQLBuilderImpl> <bindWhereAttrValue> <[378] Where binding param 3: 1> 

LKAPOOR >> EXITING doDML
LKAPOOR >> EXITING postChanges
LKAPOOR >> ENTERING ValidateEntity
LKAPOOR>> VALIDATION ID = 1
LKAPOOR >> EXITING ValidateEntity
LKAPOOR >> ENTERING postChanges
LKAPOOR>> VALIDATION ID = 1
LKAPOOR >> EXITING postChanges

<oracle.adf.model> <ViewObjectImpl> <afterCommit> <[379] ValidationVO1 notify COMMIT ... > 
<oracle.adf.model> <EntityCache> <closeStatement> <[380] EntityCache close prepared statement>

                                                                                                                                           

So, observation is that if we call any setter from doDML, then the entity is re validated, whereas if we just update an attribute then framework automatically post those values in doDML method and validateEntity() is not called again for that row.

Reference Project: ValidationProject

No comments:

Post a Comment