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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Takehata Naoto
December 09, 2020
1.2k
0
Share
MyBatis Dynamic SQLの Kotlinサポートを使う
2020年12月9日(水) 「集まれKotlin好き!Kolint愛好会 vol.26 @オンライン」の談義資料です。
Takehata Naoto
December 09, 2020
More Decks by Takehata Naoto
See All by Takehata Naoto
AI時代でも変わらない技術コミュニティの力~10年続く“ゆるい”つながりが生み出す価値
n_takehata
2
860
KotlinConf 2025で発表された言語のアップデートと現地参加レポート
n_takehata
2
360
KotlinConf 2025 現地で感じたServer-Side Kotlin
n_takehata
2
440
KotlinConf 2025 現地参加の土産話
n_takehata
0
200
組織貢献をするフリーランスエンジニアという生き方
n_takehata
1
6k
「2024年版 Kotlin サーバーサイドプログラミング実践開発」の補講 〜O/Rマッパー編〜
n_takehata
2
790
2024年版 Kotlin サーバーサイドプログラミング実践開発
n_takehata
9
8.7k
Server-Side目線で見る、Kotlin Festの楽しみ方
n_takehata
0
600
KotlinとCloud Vision APIで領収書の電子帳簿保存法対応をする
n_takehata
1
1.9k
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
660
Facilitating Awesome Meetings
lara
57
6.8k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.3k
Into the Great Unknown - MozCon
thekraken
40
2.3k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
So, you think you're a good person
axbom
PRO
2
2k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
73k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
97
Leo the Paperboy
mayatellez
5
1.6k
Ethics towards AI in product and experience design
skipperchong
2
240
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
180
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)) }
}
ここからはライブコーディングで説明します