Skip to content

Instantly share code, notes, and snippets.

Toshihiro Nakamura nakamura-to

Block or report user

Report or block nakamura-to

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nakamura-to
nakamura-to / sql-annotation.md
Last active Jan 13, 2019
Doma 2.22.0にて、SQLをアノテーションに記述するための機能を実験的に追加する
View sql-annotation.md

追加するアノテーションは @Sql の1つのみ

  • 前提として@Sql 導入前までのバージョンとの互換性は維持する
  • @Sql のFQNは org.seasar.doma.experimental.Sql

Selectの場合

(これまで通り)SQLをファイルから読む

@Select
Emp select();
@nakamura-to
nakamura-to / raw-string-literals-1.md
Last active Apr 1, 2018
Doma 3でJava 11のRaw String Literalsに対応するとしたら
View raw-string-literals-1.md

追加するアノテーションを @Sql の1つにする案

Selectの場合

SQLはファイルから読む(暗黙バージョン)

@Select
Emp select();

SQLはファイルから読む(明示バージョン)

@nakamura-to
nakamura-to / FooDao.java
Created Nov 4, 2017
可視性がパッケージレベルのDaoを使う
View FooDao.java
@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);
}
}
@nakamura-to
nakamura-to / EmployeeDao.java
Created Nov 4, 2017
Doma2でprivateメソッド
View EmployeeDao.java
@Dao
public interface EmployeeDao {
default List<Employee> selectWithBuilder() {
return selectWithBuilder_private();
}
private List<Employee> selectWithBuilder_private() {
Config config = Config.get(this);
SelectBuilder builder = SelectBuilder.newInstance(config);
@nakamura-to
nakamura-to / AppConfig.java
Last active Jul 22, 2017
RedshiftのUNLOADコマンドをDomaで生成する案
View AppConfig.java
package sample;
public class AppConfig implements Config {
@Override
public QueryImplementors getQueryImplementors() {
return new QueryImplementors() {
@Override
public SqlFileSelectQuery createSqlFileSelectQuery(Method method) {
if (method.isAnnotationPresent(Unload.class)) {
@nakamura-to
nakamura-to / Era.java
Created May 27, 2016
Doma external embeddable
View Era.java
@Entity
public class Era {
@Id
public Integer id;
public String name;
public Interval interval;
}
@nakamura-to
nakamura-to / EmbeddableSupport.kt
Last active May 25, 2016
Embeddable support in Doma (Kotlin)
View EmbeddableSupport.kt
@Embeddable
data class Address(val city: String, val street: String)
@Entity(immutable = true)
data class Person(@Id val id: Int, val name: String, val address: Address)
@nakamura-to
nakamura-to / Address.java
Last active May 25, 2016
Embeddable support in Doma
View Address.java
@Embeddable
public class Address {
private final String city;
private final String street;
public Address(String city, String street) {
this.city = city;
this.street = street;
}
public String getCity() {
return city;
@nakamura-to
nakamura-to / gist:c1c18dee82cabb8bc62d
Created Sep 13, 2015
type definitions for Redux applyMiddleware
View gist:c1c18dee82cabb8bc62d
type action = {
type: string;
};
type reducer = (state: any, action: action) => any;
type listener = () => void;
type dispatch = (action: action) => action;
View dynamic-order-by.sql
select
age, name, birthday
from
person
order by
/*%if mode == 1 */
 age, name
/*%elseif mode == 2 */
/*# "name, age" */
/*%else */
You can’t perform that action at this time.