I added such a method in Applicaion Module Impl and it is called by managed bean. updated rows echo "1", but it is really not committed to database although trans.commit() is called. What's wrong?
public void updateSSPrioritizationImportanceWeightage(ImportanceWeightage[] importanceWeightages) {
// Transaction jtaTrans = getTransaction();
//System.out.println("jtaTrans.isDirty(): "+ jtaTrans.isDirty());
DBTransaction trans = getDBTransaction();
PreparedStatement statement = null;
boolean containError =false;
String sql = " UPDATE YARD_SETTING SET value_x = ?, setting_type_c = ? WHERE setting_id = ?";
statement = trans.createPreparedStatement(sql, 2);
try {
for(int i = 0; i< importanceWeightages.length; i++){
statement.setString(1, importanceWeightages[i].getValueX());
statement.setString(2, "U");
System.out.println("importanceWeightages[i].getSettingId(): "+ importanceWeightages[i].getSettingId());
statement.setLong(3, importanceWeightages[i].getSettingId());
int rows = statement.executeUpdate();
System.out.println("updated rows: "+ rows);
System.out.println("trans.isDirty(): "+ trans.isDirty());
trans.commit();
//System.out.println("jtaTrans.isDirty(): "+ jtaTrans.isDirty());
}
} catch (SQLException s) {
containError = true;
throw new JboException(s);
} finally {
try {
if (statement != null)
statement.close();
} catch (SQLException s) {
}
try {
if(!containError){
trans.commit();
//jtaTrans.commit();
}else{
trans.rollback();
// jtaTrans.rollback();
}
} catch (Exception s) {
}
}
}
MB.
ImportanceWeightage[] importanceWeightages = populateImportanceWeightages();
if(importanceWeightages != null){
OperationBinding ob = getBindings().getOperationBinding("updateSSPrioritizationImportanceWeightage");
ob.getParamsMap().put("importanceWeightages", importanceWeightages);
ob.execute();
if(!ob.getErrors().isEmpty()){
System.out.println(ob.getErrors());
}
}