hi, i noticed some questions being asked by some people who want to use optimistic locking.
in the current release, optimistic locking will not work (only by luck, you have the chance to avoid any problems), you will not be able to update your objects. i did send a patch to this list, and thomas said he would check it in (if nobody else had already done that). however, viewing the head in CVS, the bug is still there. so anyone using current release or the head, be aware that optimistic locking might not work (with high probability) persisting your objects. Roger Janssen ************************************************************************* The information contained in this communication is confidential and is intended solely for the use of the individual or entity to whom it is addressed.You should not copy, disclose or distribute this communication without the authority of iBanx bv. iBanx bv is neither liable for the proper and complete transmission of the information has been maintained nor that the communication is free of viruses, interceptions or interference. If you are not the intended recipient of this communication please return the communication to the sender and delete and destroy all copies.
--- Begin Message ---hi, the StatementManager binds the fields/attributes used for optimistic locking in in incorrect way. it uses the wrong 'view' of field-descriptors for these fields. it uses the 'view' of 'all non PK fields' where it should use the view of 'all locking fields'. currently, in binding the locking field, it uses the positional-index of the field within the 'all locking fields' view to retrieve the field-descriptor from the 'all non PK fields' view. obviously they do not need to match, so it retrieves the wrong field descriptor which is used to calculate the datatype of the field. so if you are lucky, if the datatypes match, you won't notice anything, but if you're unlucky, wrongfull SQL is being generated and an java.sql.SQLException is being thrown. For instance, the current implementation of the HiLow sequence manager only works by 'luck' (the version-locking fields has the same datatype as the first non PK field in the 'all non PK fields' view). this bug results in not being able to use optimistic locking, you will be unable to update you're objects. below is a patch (which imho fixes the bug) for org.apache.ojb.broker.accesslayer.StatementManager. changed code is marked with 'iBanx patch', only two lines! ______________________ patch _________________________________ /** * binds the values of the object obj to the statements parameters */ public void bindUpdate(PreparedStatement stmt, ClassDescriptor cld, Object obj) throws java.sql.SQLException { int index = 1; Object[] values, currentLockingValues; currentLockingValues = cld.getCurrentLockingValues(obj); cld.updateLockingValues(obj); // BRJ values = getNonKeyValues(m_broker, cld, obj); // parameters for SET-clause for (int i = 0; i < values.length; i++) { Object val = values[i]; if (val != null) m_platform.setObjectForStatement(stmt, index, val, SqlHelper.getSqlTypeRwNonPk(cld, i)); else m_platform.setNullForStatement(stmt, index, SqlHelper.getSqlTypeRwNonPk(cld, i)); index++; } // parameters for WHERE-clause pk values = getKeyValues(m_broker, cld, obj); for (int i = 0; i < values.length; i++) { Object val = values[i]; if (val != null) { stmt.setObject(index, values[i], SqlHelper.getSqlTypePk(cld, i)); } else { stmt.setNull(index, SqlHelper.getSqlTypePk(cld, i)); } index++; } // parameters for WHERE-clause locking values = currentLockingValues; for (int i = 0; i < values.length; i++) { Object val = values[i]; if (val != null) { // iBanx patch stmt.setObject(index, values[i], SqlHelper.getSqlTypeLocking(cld, i)); //stmt.setObject(index, values[i], SqlHelper.getSqlTypeRwNonPk(cld, i)); // end patch } else { // iBanx patch stmt.setNull(index, SqlHelper.getSqlTypeLocking(cld, i)); //stmt.setNull(index, SqlHelper.getSqlTypeRwNonPk(cld, i)); // end patch } index++; } } ________________________ end patch __________________________________ can any ojb developer please apply this patch in CVS. (since i use optimistic locking, to check whether objects have been modified, througout my whole application, this is a showstopper for me!) thanx, roger janssen ************************************************************************* The information contained in this communication is confidential and is intended solely for the use of the individual or entity to whom it is addressed.You should not copy, disclose or distribute this communication without the authority of iBanx bv. iBanx bv is neither liable for the proper and complete transmission of the information has been maintained nor that the communication is free of viruses, interceptions or interference. If you are not the intended recipient of this communication please return the communication to the sender and delete and destroy all copies. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--- End Message ---
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
