/** * Sets the named field to the passed value, even if the value is null * * @param name The field name to set * @param value The value to set */ public void set(String name, Object value) { set(name, value, true); }
/** Sets the named field to the passed value, even if the value is null * @param name The field name to set * @param value The value to set */ public void set(String name, Object value) { set(name, value, true); }
/** Sets the named field to the passed value, even if the value is null * @param name The field name to set * @param value The value to set */ public void set(String name, Object value) { set(name, value, true); }
public Object put(Object key, Object value) { return this.set((String) key, value, true); }
public Object put(Object key, Object value) { return this.set((String) key, value, true); }
public Object put(String key, Object value) { return this.set(key, value, true); }
/** * Updates the given fields of this entity with the values in the given map, including nulls. * * @param newFieldValues map of valid field names to new values; if null, this method does nothing */ public void setFields(final Map<? extends String, ?> newFieldValues) { if (newFieldValues == null) { return; } // We could implement this with Map.putAll, but this way validates the given field names for (final Entry<? extends String, ?> update : newFieldValues.entrySet()) { set(update.getKey(), update.getValue(), true); } }
/** Used by clients to update particular fields in the entity * @param keyValuePairs java.util.Map */ public synchronized void setFields(Map keyValuePairs) { if (keyValuePairs == null) return; Iterator entries = keyValuePairs.entrySet().iterator(); Map.Entry anEntry = null; // this could be implement with Map.putAll, but we'll leave it like this for the extra features it has while (entries.hasNext()) { anEntry = (Map.Entry) entries.next(); this.set((String) anEntry.getKey(), anEntry.getValue(), true); } }
/** Used by clients to update particular fields in the entity * @param keyValuePairs java.util.Map */ public synchronized void setFields(Map keyValuePairs) { if (keyValuePairs == null) return; Iterator entries = keyValuePairs.entrySet().iterator(); Map.Entry anEntry = null; // this could be implement with Map.putAll, but we'll leave it like this for the extra features it has while (entries.hasNext()) { anEntry = (Map.Entry) entries.next(); this.set((String) anEntry.getKey(), anEntry.getValue(), true); } }
/** Sets a field with an array of bytes, wrapping them automatically for easy use. * @param name The field name to set * @param bytes The byte array to be wrapped and set */ public void setBytes(String name, byte[] bytes) { this.set(name, new ByteWrapper(bytes)); }
/** Sets a field with an array of bytes, wrapping them automatically for easy use. * @param name The field name to set * @param bytes The byte array to be wrapped and set */ public void setBytes(String name, byte[] bytes) { this.set(name, new ByteWrapper(bytes)); }
/** * Sets a field with an array of bytes, wrapping them automatically for easy use. * * @param name The field name to set * @param bytes The byte array to be wrapped and set */ public void setBytes(String name, byte[] bytes) { this.set(name, new ByteWrapper(bytes)); }
private int singleInsert(GenericEntity entity, ModelEntity modelEntity, List fieldsToSave, Connection connection) throws GenericEntityException { if (modelEntity instanceof ModelViewEntity) { return singleUpdateView(entity, (ModelViewEntity) modelEntity, fieldsToSave, connection); } // if we have a STAMP_FIELD then set it with NOW. if (modelEntity.isField(ModelEntity.STAMP_FIELD)) { entity.set(ModelEntity.STAMP_FIELD, UtilDateTime.nowTimestamp()); } String sql = "INSERT INTO " + modelEntity.getTableName(datasourceInfo) + " (" + modelEntity.colNameString(fieldsToSave) + ") VALUES (" + modelEntity.fieldsStringList(fieldsToSave, "?", ", ") + ")"; SQLProcessor sqlP = new PassThruSQLProcessor(helperName, connection); try { sqlP.prepareStatement(sql); SqlJdbcUtil.setValues(sqlP, fieldsToSave, entity, modelFieldTypeReader); int retVal = sqlP.executeUpdate(); entity.modified = false; if (entity instanceof GenericValue) { ((GenericValue) entity).copyOriginalDbValues(); } return retVal; } catch (GenericEntityException e) { throw new GenericEntityException("while inserting: " + entity.toString(), e); } finally { sqlP.close(); } }
private int singleInsert(GenericEntity entity, ModelEntity modelEntity, List fieldsToSave, Connection connection) throws GenericEntityException { if (modelEntity instanceof ModelViewEntity) { return singleUpdateView(entity, (ModelViewEntity) modelEntity, fieldsToSave, connection); } // if we have a STAMP_FIELD then set it with NOW. if (modelEntity.isField(ModelEntity.STAMP_FIELD)) { entity.set(ModelEntity.STAMP_FIELD, UtilDateTime.nowTimestamp()); } String sql = "INSERT INTO " + modelEntity.getTableName(datasourceInfo) + " (" + modelEntity.colNameString(fieldsToSave) + ") VALUES (" + modelEntity.fieldsStringList(fieldsToSave, "?", ", ") + ")"; SQLProcessor sqlP = new PassThruSQLProcessor(helperName, connection); try { sqlP.prepareStatement(sql); SqlJdbcUtil.setValues(sqlP, fieldsToSave, entity, modelFieldTypeReader); int retVal = sqlP.executeUpdate(); entity.modified = false; if (entity instanceof GenericValue) { ((GenericValue) entity).copyOriginalDbValues(); } return retVal; } catch (GenericEntityException e) { throw new GenericEntityException("while inserting: " + entity.toString(), e); } finally { sqlP.close(); } }
private int singleInsert(GenericEntity entity, ModelEntity modelEntity, List<ModelField> fieldsToSave, Connection connection) throws GenericEntityException { if (modelEntity instanceof ModelViewEntity) { return singleUpdateView(entity, (ModelViewEntity) modelEntity, fieldsToSave, connection); } // if we have a STAMP_FIELD then set it with NOW. if (modelEntity.isField(ModelEntity.STAMP_FIELD)) { entity.set(ModelEntity.STAMP_FIELD, UtilDateTime.nowTimestamp()); } final String sql = "INSERT INTO " + modelEntity.getTableName(datasourceInfo) + " (" + modelEntity.colNameString(fieldsToSave) + ") VALUES (" + modelEntity.fieldsStringList(fieldsToSave, "?", ", ") + ')'; SQLProcessor sqlP = new PassThruSQLProcessor(helperName, connection); try { sqlP.prepareStatement(sql); SqlJdbcUtil.setValues(sqlP, fieldsToSave, entity, modelFieldTypeReader); int retVal = sqlP.executeUpdate(); entity.modified = false; if (entity instanceof GenericValue) { ((GenericValue) entity).copyOriginalDbValues(); } return retVal; } catch (GenericEntityException e) { throw new GenericEntityException("while inserting: " + entity.toString(), e); } finally { closeSafely(sql, sqlP); } }