@UseStringTemplate3StatementLocator() @RegisterContainerMapper(QueryKeys.QueryKeysContainerFactory.class) public interface QueryKeys
MyCustomizer(RegisterContainerMapper annotation) { List<ContainerFactory> ls = new ArrayList<ContainerFactory>(); try { for (Class<? extends ContainerFactory> type : annotation.value()) { ls.add(type.newInstance()); } } catch (Exception e) { throw new IllegalStateException("Unable to instantiate container factory", e); } this.factory = ls; }
MyCustomizer(RegisterContainerMapper annotation) { List<ContainerFactory> ls = new ArrayList<ContainerFactory>(); try { for (Class<? extends ContainerFactory> type : annotation.value()) { ls.add(type.newInstance()); } } catch (Exception e) { throw new IllegalStateException("Unable to instantiate container factory", e); } this.factory = ls; }
@RegisterContainerMapper({ImmutableListContainerFactory.class, MaybeContainerFactory.class}) public static interface Dao extends Base<String> { @SqlQuery("select name from something order by id") public ImmutableList<String> findAll(); @SqlQuery("select name from something order by id") public Set<String> findAllAsSet(); @SqlUpdate("insert into something (id, name) values (:id, :name)") public void insert(@BindBean Something it); @SqlQuery("select name from something where id = :id") @SingleValueResult(String.class) public Maybe<String> findNameById(@Bind("id") int id); @SqlQuery("select name from something where id = :id") @SingleValueResult public Maybe<String> smartFindNameById(@Bind("id") int id); }
@RegisterContainerMapper({ImmutableListContainerFactory.class, MaybeContainerFactory.class}) public static interface Dao extends Base<String> { @SqlQuery("select name from something order by id") public ImmutableList<String> findAll(); @SqlQuery("select name from something order by id") public Set<String> findAllAsSet(); @SqlUpdate("insert into something (id, name) values (:id, :name)") public void insert(@BindBean Something it); @SqlQuery("select name from something where id = :id") @SingleValueResult(String.class) public Maybe<String> findNameById(@Bind("id") int id); @SqlQuery("select name from something where id = :id") @SingleValueResult public Maybe<String> smartFindNameById(@Bind("id") int id); }
@UseStringTemplate3StatementLocator @RegisterContainerMapper(ImmutableSetContainerFactory.class) public static interface DAO { @SqlQuery public ImmutableSet<String> findIdsForNames(@BindIn("names") List<Integer> names); }
@UseStringTemplate3StatementLocator @RegisterContainerMapper(ImmutableSetContainerFactory.class) public static interface DAO { @SqlQuery public ImmutableSet<String> findIdsForNames(@BindIn("names") List<Integer> names); }
@RegisterContainerMapper(TestContainerFactory.ImmutableListContainerFactory.class) @RegisterMapper(SomethingMapper.class) public static interface Sql { @SqlBatch("insert into something (id, name) values (:id, :name)") public int[] insert(@Bind("id") Iterable<Integer> ids, @Bind("name") Iterable<String> names); @SqlQuery("select id, name from something where id > :end_of_last_page order by id limit :size") public ImmutableList<Something> loadPage(@Bind("end_of_last_page") int last, @Bind("size") int size); }
@RegisterContainerMapper(TestContainerFactory.ImmutableListContainerFactory.class) @RegisterMapper(SomethingMapper.class) public static interface Sql { @SqlBatch("insert into something (id, name) values (:id, :name)") public int[] insert(@Bind("id") Iterable<Integer> ids, @Bind("name") Iterable<String> names); @SqlQuery("select id, name from something where id > :end_of_last_page order by id limit :size") public ImmutableList<Something> loadPage(@Bind("end_of_last_page") int last, @Bind("size") int size); }