ラムダで指定できなくはないが、型パラメータが面倒臭いことになる
val query = select({ it.name }, from = ::_Emp) { e -> where { eq(e.id, 1) }}
// 下記の記事の最後のコード例をKotlinで書いてみた | |
// https://zenn.dev/hinastory/articles/c8d5267ea43ed6 | |
package hello.kotlin | |
data class Person(val name: String, val age: Int) | |
data class Japanese(val name: String, val age: Int, val info: String) | |
interface CanGreet<T> { | |
fun T.hello() |
val d = Dept.meta | |
val e = Emp.meta | |
val query = SqlDsl.from(d).innerJoin(e){ d.id eq e.deptId }.associate(d, e) | |
val aggregate = db.runQuery { query } | |
val map: Map<Dept, Set<Emp>> = aggregate.oneToMany(d, e) |
public class Address { | |
public String ctiy; | |
public String street; | |
public Address(String city, String street) { | |
this.city = ctiy; | |
this.street = street; | |
} | |
} |
fun String.globalExtension() { | |
println(this) | |
} | |
class Scope { | |
fun String.narrowExtension() { | |
println(this) | |
} | |
} |
package org.komapper.quickstart | |
import org.komapper.annotation.KomapperAutoIncrement | |
import org.komapper.annotation.KomapperEntity | |
import org.komapper.annotation.KomapperId | |
import org.komapper.core.dsl.EntityDsl | |
import org.komapper.core.dsl.SchemaDsl | |
import org.komapper.core.dsl.expression.ColumnExpression | |
import org.komapper.core.dsl.scope.WhereDeclaration | |
import org.komapper.jdbc.JdbcDatabase |
val query = select(::_製品移動) { a -> | |
val b = leftJoin(::_倉庫) { b -> | |
eq(a.移送元倉庫id, b.倉庫id) | |
} | |
val c = leftJoin(::_倉庫) { c -> | |
eq(a.移送先倉庫id, c.倉庫id) | |
} | |
associate(a, b) { 製品移動, 倉庫 -> | |
製品移動.移送元倉庫 = 倉庫 | |
} |
@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); | |
} | |
} |