/** * Populate the INSERT clause with the properties of the given bean using * the given Mapper. * * @param obj * @param mapper * @return */ @SuppressWarnings("rawtypes") public <T> SQLInsertClause populate(T obj, Mapper<T> mapper) { Map<Path<?>, Object> values = mapper.createMap(entity, obj); for (Map.Entry<Path<?>, Object> entry : values.entrySet()) { set((Path) entry.getKey(), entry.getValue()); } return this; }
/** * Populate the UPDATE clause with the properties of the given bean using the given Mapper. * * @param obj * @param mapper * @return */ @SuppressWarnings({ "rawtypes", "unchecked" }) public <T> SQLUpdateClause populate(T obj, Mapper<T> mapper) { Collection<? extends Path<?>> primaryKeyColumns = entity.getPrimaryKey() != null ? entity.getPrimaryKey().getLocalColumns() : Collections.<Path<?>>emptyList(); Map<Path<?>, Object> values = mapper.createMap(entity, obj); for (Map.Entry<Path<?>, Object> entry : values.entrySet()) { if (!primaryKeyColumns.contains(entry.getKey())) { set((Path)entry.getKey(), entry.getValue()); } } return this; }