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
770
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
KotlinとCloud Vision APIで領収書の電子帳簿保存法対応をする / Cloud Vision API with Kotlin
n_takehata
1
77
KotlinConf 2023 現地参加レポート
n_takehata
1
240
サーバーサイドKotlinクイズ
n_takehata
0
110
サーバーサイドでのKotlin Coroutines
n_takehata
0
890
KotlessとDynamoDBで自分のツイートを収集するサーバーレスアプリケーションを作る
n_takehata
0
290
書籍『Kotlin サーバーサイドプログラミング実践開発』のこだわりとおすすめポイント
n_takehata
0
420
Server-Side Kotlinで必要なJavaの知識
n_takehata
1
410
grpc-kotlinはどこまでKotlin化できるのか?
n_takehata
0
730
サーバサイドKotlinでgRPCをやってみよう
n_takehata
1
7.4k
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
60
4k
Writing Fast Ruby
sferik
622
60k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
358
22k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
155
14k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
123
39k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
9
1.3k
Building Effective Engineering Teams - LeadDev
addyosmani
33
1.9k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
34
6.1k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
Agile that works and the tools we love
rasmusluckow
325
20k
Robots, Beer and Maslow
schacon
PRO
155
8k
The Pragmatic Product Professional
lauravandoore
26
5.9k
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)) }
}
ここからはライブコーディングで説明します