Skip to content

Commit

Permalink
Fix sample code
Browse files Browse the repository at this point in the history
  • Loading branch information
nakamura-to committed Nov 23, 2023
1 parent 8501b1a commit d7e4f7c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion content/en/docs/Reference/data-type.md
Expand Up @@ -56,6 +56,7 @@ class AgeType : JdbcUserDefinedDataType<Age> {
}

override fun setValue(ps: PreparedStatement, index: Int, value: Age) {
// The second argument must be a type corresponding to the jdbcType property.
ps.setInt(index, value.value)
}

Expand Down Expand Up @@ -96,7 +97,7 @@ class AgeType : R2dbcUserDefinedDataType<Age> {

override val klass: KClass<Age> = Age::class

override val javaObjectType: Class<*> = Int::class.javaObjectType
override val r2dbcType: Class<Int> = Int::class.javaObjectType

override fun getValue(row: Row, index: Int): Age? {
return row.get(index, Int::class.javaObjectType)?.let { Age(it) }
Expand All @@ -107,10 +108,12 @@ class AgeType : R2dbcUserDefinedDataType<Age> {
}

override fun setValue(statement: Statement, index: Int, value: Age) {
// The second argument must be of the same type as the r2dbcType property.
statement.bind(index, value.value)
}

override fun setValue(statement: Statement, name: String, value: Age) {
// The second argument must be of the same type as the r2dbcType property.
statement.bind(name, value.value)
}

Expand Down
5 changes: 4 additions & 1 deletion content/ja/docs/Reference/data-type.md
Expand Up @@ -55,6 +55,7 @@ class AgeType : JdbcUserDefinedDataType<Age> {
}

override fun setValue(ps: PreparedStatement, index: Int, value: Age) {
// 第二引数はjdbcTypeプロパティに対応する型でなければいけません
ps.setInt(index, value.value)
}

Expand Down Expand Up @@ -95,7 +96,7 @@ class AgeType : R2dbcUserDefinedDataType<Age> {

override val klass: KClass<Age> = Age::class

override val javaObjectType: Class<*> = Int::class.javaObjectType
override val r2dbcType: Class<Int> = Int::class.javaObjectType

override fun getValue(row: Row, index: Int): Age? {
return row.get(index, Int::class.javaObjectType)?.let { Age(it) }
Expand All @@ -106,10 +107,12 @@ class AgeType : R2dbcUserDefinedDataType<Age> {
}

override fun setValue(statement: Statement, index: Int, value: Age) {
// 第二引数はr2dbcTypeプロパティと同じ型でなければいけません
statement.bind(index, value.value)
}

override fun setValue(statement: Statement, name: String, value: Age) {
// 第二引数はr2dbcTypeプロパティと同じ型でなければいけません
statement.bind(name, value.value)
}

Expand Down

0 comments on commit d7e4f7c

Please sign in to comment.