/** * Populate the INSERT clause with the properties of the given bean using * the given Mapper. * * @param obj object to use for population * @param mapper mapper to use * @return the current object */ @SuppressWarnings("rawtypes") @WithBridgeMethods(value = SQLInsertClause.class, castRequired = true) public <T> C 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 (C) this; }
/** * Populate the UPDATE clause with the properties of the given bean using the given Mapper. * * @param obj object to use for population * @param mapper mapper to use * @return the current object */ @SuppressWarnings({ "rawtypes", "unchecked" }) @WithBridgeMethods(value = SQLUpdateClause.class, castRequired = true) public <T> C 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 (C) this; }