/** * Get a configuration's settings or default settings if the configuration * is <code>null</code>. */ static final Settings settings(Configuration configuration) { return configuration(configuration).settings(); }
/** * Get an attachable's configuration or a new {@link DefaultConfiguration} * if <code>null</code>. */ static final Configuration configuration(Attachable attachable) { return configuration(attachable.configuration()); }
/** * Get a configuration's settings or default settings if the configuration * is <code>null</code>. */ static final Settings settings(Attachable attachable) { return configuration(attachable).settings(); }
@Override public /* non-final */ SQLDialect dialect() { return Tools.configuration(configuration()).dialect(); }
@Override public final SQLDialect dialect() { return Tools.configuration(configuration()).dialect(); }
@Override public final SQLDialect dialect() { return Tools.configuration(configuration()).dialect(); }
@Override public final <K, V> Map<K, List<V>> intoGroups(Class<? extends K> keyType, Class<? extends V> valueType) { return intoGroups( Tools.configuration(this).recordMapperProvider().provide(fields, keyType), Tools.configuration(this).recordMapperProvider().provide(fields, valueType) ); }
@Override public final <E> List<E> into(Class<? extends E> type) { List<E> list = new ArrayList<E>(size()); RecordMapper<R, E> mapper = Tools.configuration(this).recordMapperProvider().provide(fields, type); for (R record : this) list.add(mapper.map(record)); return list; }
/** * Inject a configuration. * <p> * This method is maintained to be able to configure a <code>DAO</code> * using Spring. It is not exposed in the public API. */ public /* non-final */ void setConfiguration(Configuration configuration) { this.configuration = configuration; this.mapper = Tools.configuration(configuration).recordMapperProvider().provide(table.recordType(), type); }
@Override public final <K, E> Map<K, List<E>> intoGroups(Field<K> key, Class<? extends E> type) { return intoGroups(key, Tools.configuration(this).recordMapperProvider().provide(fields, type)); }
@Override public final <K, V> Map<K, List<V>> intoGroups(Class<? extends K> keyType, RecordMapper<? super R, V> valueMapper) { return intoGroups(Tools.configuration(this).recordMapperProvider().provide(fields, keyType), valueMapper); }
@Override public final <E, S extends Record> Map<S, List<E>> intoGroups(Table<S> table, Class<? extends E> type) { return intoGroups(table, Tools.configuration(this).recordMapperProvider().provide(fields, type)); }
@Override public final <E> Map<?, E> intoMap(Name keyFieldName, Class<? extends E> type) { return intoMap(keyFieldName, Tools.configuration(this).recordMapperProvider().provide(fields, type)); }
@Override public final <E> Map<Record, List<E>> intoGroups(int[] keyFieldIndexes, Class<? extends E> type) { return intoGroups(keyFieldIndexes, Tools.configuration(this).recordMapperProvider().provide(fields, type)); }
@Override public final <K, V> Map<K, List<V>> intoGroups(RecordMapper<? super R, K> keyMapper, Class<V> valueType) { return intoGroups(keyMapper, Tools.configuration(this).recordMapperProvider().provide(fields, valueType)); }
@Override public CompletionStage<Void> transactionAsync(TransactionalRunnable transactional) { return transactionAsync(Tools.configuration(configuration()).executorProvider().provide(), transactional); }
@Override public <T> CompletionStage<T> transactionResultAsync(TransactionalCallable<T> transactional) { return transactionResultAsync(Tools.configuration(configuration()).executorProvider().provide(), transactional); }
@Override public CompletionStage<Result<Record>> fetchAsync(ResultSet rs, DataType<?>... types) { return fetchAsync(Tools.configuration(configuration()).executorProvider().provide(), rs, types); }
private final void from0(Object source, Fields f) { if (source == null) return; // [#2520] TODO: Benchmark this from() method. There's probably a better implementation from(Tools.configuration(this).recordUnmapperProvider().provide(source.getClass(), f).unmap(prepareArrayForUnmap(source, f))); // [#2700] [#3582] If a POJO attribute is NULL, but the column is NOT NULL // then we should let the database apply DEFAULT values resetChangedOnNotNull(this); }
/** * Use a previously obtained set of records as a new Table */ @Support public static <R extends Record> Table<R> table(R... records) { if (records == null || records.length == 0) return (Table<R>) new Dual(); Result<R> result = new ResultImpl(configuration(records[0]), records[0].fields()); result.addAll(Arrays.asList(records)); return table(result); }