Skip to content

Instantly share code, notes, and snippets.

@nakamura-to
Created November 4, 2017 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nakamura-to/7f92d7e16810615d5f7d19a72d744e84 to your computer and use it in GitHub Desktop.
Save nakamura-to/7f92d7e16810615d5f7d19a72d744e84 to your computer and use it in GitHub Desktop.
可視性がパッケージレベルのDaoを使う
@Dao
public interface FooDao {
public default <R> R findByIds(List<FooId> ids, Collector<Foo, ?, R> collctor) {
FooInteranlDao dao = DaoFactory.get(FooInteranlDao.class);
return Lists.partition(ids, 5000).stream() // partition は List<A> を 第二引数の数ごと区切ってList<List<A>> にする処理です
flatMap(dao::findByIdsInternally)
collect(collctor);
}
}
@Dao(accessLevel = AccessLevel.PACKAGE)
interface FooInteranlDao {
@Select(strategy = SelectType.STREAM)
@Suppress(messages = { Message.DOMA4274 })
Stream<Foo> findByIdsInternally(List<FooId> ids);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment