use of org.simpleflatmapper.jdbc.JdbcMapperFactory in project SimpleFlatMapper by arnaudroger.
the class TestMapFooBar method mapFooBarNoBuilderLink.
@Test
public void mapFooBarNoBuilderLink() throws NoSuchMethodException {
final JdbcMapperFactory mapperFactory = JdbcMapperFactory.newInstance();
final ClassMeta<FoobarValueNoBuilderLink> meta = mapperFactory.getClassMetaWithExtraInstantiator(FoobarValueNoBuilderLink.class, ImmutableFoobarValueNoBuilderLink.class.getMethod("builder"));
final JdbcMapperBuilder<FoobarValueNoBuilderLink> builder = mapperFactory.newBuilder(meta);
assertNotNull(builder.addKey("foo").addKey("bar").addKey("crux").mapper());
}
use of org.simpleflatmapper.jdbc.JdbcMapperFactory in project SimpleFlatMapper by arnaudroger.
the class JdbcTemplateCrudDSL method to.
public JdbcTemplateCrud<T, K> to(JdbcOperations jdbcOperations, final String table) {
final JdbcMapperFactory factory = JdbcMapperFactory.newInstance(jdbcTemplateMapperFactory);
Crud<T, K> crud = jdbcOperations.execute(new ConnectionCallback<Crud<T, K>>() {
@Override
public Crud<T, K> doInConnection(Connection connection) throws SQLException, DataAccessException {
return factory.<T, K>crud(target, keyTarget).table(connection, table);
}
});
return new JdbcTemplateCrud<T, K>(jdbcOperations, crud);
}
use of org.simpleflatmapper.jdbc.JdbcMapperFactory in project SimpleFlatMapper by arnaudroger.
the class JdbcTemplateCrudDSL method lazilyTo.
public JdbcTemplateCrud<T, K> lazilyTo(JdbcOperations jdbcOperations) {
final JdbcMapperFactory factory = JdbcMapperFactory.newInstance(jdbcTemplateMapperFactory);
Crud<T, K> crud = factory.<T, K>crud(target, keyTarget).crud();
return new JdbcTemplateCrud<T, K>(jdbcOperations, crud);
}
use of org.simpleflatmapper.jdbc.JdbcMapperFactory in project SimpleFlatMapper by arnaudroger.
the class JdbcTemplateCrudDSL method lazilyTo.
public JdbcTemplateCrud<T, K> lazilyTo(JdbcOperations jdbcOperations, final String table) {
final JdbcMapperFactory factory = JdbcMapperFactory.newInstance(jdbcTemplateMapperFactory);
Crud<T, K> crud = factory.<T, K>crud(target, keyTarget).table(table);
return new JdbcTemplateCrud<T, K>(jdbcOperations, crud);
}
use of org.simpleflatmapper.jdbc.JdbcMapperFactory in project SimpleFlatMapper by arnaudroger.
the class JdbcMapperCustomMappingTest method testColumnAliasStatic.
@Test
public void testColumnAliasStatic() throws Exception {
JdbcMapperFactory mapperFactory = JdbcMapperFactoryHelper.asm();
mapperFactory.addAlias("not_id_column", "id");
final JdbcMapper<DbObject> mapper = JdbcMapperDbObjectTest.addColumn(mapperFactory.newBuilder(DbObject.class)).mapper();
DbHelper.testQuery(new TestRowHandler<PreparedStatement>() {
@Override
public void handle(PreparedStatement t) throws Exception {
ResultSet r = t.executeQuery();
r.next();
DbHelper.assertDbObjectMapping(mapper.map(r));
}
}, DbHelper.TEST_DB_OBJECT_QUERY.replace("id,", "id as not_id_column,"));
}
Aggregations