protected void setupUpdateBindVariables(Object bean) { final List<Object> varList = new ArrayList<Object>(); final List<ValueType> varValueTypeList = new ArrayList<ValueType>(); final BeanMetaData bmd = getBeanMetaData(); final String timestampPropertyName = bmd.getTimestampPropertyName(); final String versionNoPropertyName = bmd.getVersionNoPropertyName(); for (int i = 0; i < propertyTypes.length; ++i) { PropertyType pt = propertyTypes[i]; if (pt.getPropertyName().equalsIgnoreCase(timestampPropertyName)) { setTimestamp(new Timestamp(new Date().getTime())); varList.add(getTimestamp()); } else if (pt.getPropertyName().equalsIgnoreCase(versionNoPropertyName)) { if (!isVersionNoAutoIncrementOnMemory()) { continue; // because of always 'VERSION_NO = VERSION_NO + 1' } Object value = pt.getPropertyDesc().getValue(bean); if (value == null) { continue; // because of 'VERSION_NO = VERSION_NO + 1' } int intValue = IntegerConversionUtil.toPrimitiveInt(value) + 1; setVersionNo(new Integer(intValue)); varList.add(getVersionNo()); } else { varList.add(pt.getPropertyDesc().getValue(bean)); } varValueTypeList.add(pt.getValueType()); } addAutoUpdateWhereBindVariables(varList, varValueTypeList, bean); setBindVariables(varList.toArray()); setBindVariableValueTypes( (ValueType[]) varValueTypeList.toArray(new ValueType[varValueTypeList.size()])); }
@Override protected void incrementVersions() { if (includeVersion) { return; } final Field field = entityMeta.getVersionPropertyMeta().getField(); for (final T entity : entities) { if (field.getType() == int.class || field.getType() == Integer.class) { final int version = IntegerConversionUtil.toPrimitiveInt(FieldUtil.get(field, entity)) + 1; FieldUtil.set(field, entity, Integer.valueOf(version)); } else if (field.getType() == long.class || field.getType() == Long.class) { final long version = LongConversionUtil.toPrimitiveLong(FieldUtil.get(field, entity)) + 1; FieldUtil.set(field, entity, Long.valueOf(version)); } } }