Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
MyBatis Dynamic SQLの Kotlinサポートを使う
Search
Takehata Naoto
December 09, 2020
0
760
MyBatis Dynamic SQLの Kotlinサポートを使う
2020年12月9日(水) 「集まれKotlin好き!Kolint愛好会 vol.26 @オンライン」の談義資料です。
Takehata Naoto
December 09, 2020
Tweet
Share
More Decks by Takehata Naoto
See All by Takehata Naoto
KotlinConf 2023 現地参加レポート
n_takehata
1
220
サーバーサイドKotlinクイズ
n_takehata
0
100
サーバーサイドでのKotlin Coroutines
n_takehata
0
840
KotlessとDynamoDBで自分のツイートを収集するサーバーレスアプリケーションを作る
n_takehata
0
270
書籍『Kotlin サーバーサイドプログラミング実践開発』のこだわりとおすすめポイント
n_takehata
0
410
Server-Side Kotlinで必要なJavaの知識
n_takehata
1
390
grpc-kotlinはどこまでKotlin化できるのか?
n_takehata
0
700
サーバサイドKotlinでgRPCをやってみよう
n_takehata
1
7.4k
Unity C# × gRPC × サーバーサイドKotlinによる次世代のサーバー/クライアント通信 〜ハイパフォーマンスな通信基盤の開発とMagicOnionによるリアルタイム通信の実現〜
n_takehata
2
1.6k
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
27
6.3k
Designing for humans not robots
tammielis
247
25k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
101
6.6k
Build your cross-platform service in a week with App Engine
jlugia
223
17k
The Invisible Side of Design
smashingmag
293
49k
Designing Experiences People Love
moore
135
23k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3k
Scaling GitHub
holman
456
140k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
111
35k
Product Roadmaps are Hard
iamctodd
43
9.6k
Imperfection Machines: The Place of Print at Facebook
scottboms
257
12k
The Straight Up "How To Draw Better" Workshop
denniskardys
227
130k
Transcript
MyBatis Dynamic SQLの Kotlinサポートを使う 2020年12月9日 Kotlin愛好会 vol.26 竹端 尚人
自己紹介
概要 竹端 尚人 Twitter: @n_takehata • サーバーサイドKotlin • (少し前まで)スマートフォンゲーム開発 •
今月からフリーランス
登壇、執筆 • CEDEC 2018登壇 • CEDEC 2019登壇 • Software Design
2019年2月号〜4月号で短期連載 「サーバーサイド開発の品質を向上させる Java→Kotlin 移行のススメ」執筆
本日の内容
MyBatis Dynamic SQLのKotlinでの使い方を ライブコーディングで説明します
MyBatisとは?
• JavaのポピュラーなO/Rマッパーの一つ • もともとXMLにSQLを記述し、インターフェースとマッピング する方式 • XMLやInterface、Modelクラスなどのボイラープレートを生 成するGeneratorがある Java製のO/Rマッパー
XMLの例(抜粋) <insert id="insertSelective" parameterType="love.kotlin.server.crud.database.User" > insert into user <trim prefix="("
suffix=")" suffixOverrides=","> <if test="id != null"> id, </if> <if test="name != null"> name, </if> <if test="age != null"> age,
インターフェースの例(抜粋) @Insert({ "insert into user (id, name, " , "age)",
"values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, " , "#{age,jdbcType=INTEGER})" }) int insert(User record); int insertSelective(User record);
MyBatis Dynamyc SQL
• コード上でSQLを構築できる • こちらもGeneratorによる自動生成に対応 • Kotlinでのコードも生成可能に MyBatisで動的SQL生成のスタック
fun findAll(): List<User> { return userMapper.select { where(id, isEqualTo(1)) }
}
ここからはライブコーディングで説明します