forked from medly/norm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
8 changed files
with
114 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.foo | ||
|
||
import java.sql.PreparedStatement | ||
import java.sql.ResultSet | ||
import kotlin.Int | ||
import kotlin.String | ||
import norm.ParamSetter | ||
import norm.Query | ||
import norm.RowMapper | ||
|
||
data class FooParams( | ||
val name: String?, | ||
val field: String? | ||
) | ||
|
||
class FooParamSetter : ParamSetter<FooParams> { | ||
override fun map(ps: PreparedStatement, params: FooParams) { | ||
ps.setObject(1, params.name) | ||
ps.setObject(2, params.field) | ||
} | ||
} | ||
|
||
data class FooResult( | ||
val id: Int, | ||
val firstName: String?, | ||
val lastName: String? | ||
) | ||
|
||
class FooRowMapper : RowMapper<FooResult> { | ||
override fun map(rs: ResultSet): FooResult = FooResult( | ||
id = rs.getObject("id") as kotlin.Int, | ||
firstName = rs.getObject("first_name") as kotlin.String?, | ||
lastName = rs.getObject("last_name") as kotlin.String?) | ||
} | ||
|
||
class FooQuery : Query<FooParams, FooResult> { | ||
override val sql: String = "select * from employees where first_name = ? order by ?" | ||
|
||
override val mapper: RowMapper<FooResult> = FooRowMapper() | ||
|
||
override val paramSetter: ParamSetter<FooParams> = FooParamSetter() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters