Skip to content

Commit 797f6f5

Browse files
committed
Repackage the MyBatis3 Example - prepring for a Spring example
1 parent f24aee5 commit 797f6f5

27 files changed

+72
-75
lines changed

src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/mybatis3/MapperSupportFunctions.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ import org.mybatis.dynamic.sql.select.QueryExpressionDSL
2424
import org.mybatis.dynamic.sql.select.SelectModel
2525
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider
2626
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider
27-
import org.mybatis.dynamic.sql.util.kotlin.CountCompleter
28-
import org.mybatis.dynamic.sql.util.kotlin.DeleteCompleter
29-
import org.mybatis.dynamic.sql.util.kotlin.SelectCompleter
30-
import org.mybatis.dynamic.sql.util.kotlin.UpdateCompleter
27+
import org.mybatis.dynamic.sql.util.kotlin.*
3128

3229
fun count(mapper: (SelectStatementProvider) -> Long, table: SqlTable, completer: CountCompleter) =
3330
mapper(count(table, completer))

src/site/markdown/docs/kotlin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ MyBatis Dynamic SQL includes Kotlin extension methods that enable an SQL DSL for
33

44
The standard usage patterns for MyBatis Dynamic SQL and MyBatis3 in Java must be modified somewhat for Kotlin. Kotlin interfaces can contain both abstract and non-abstract methods (somewhat similar to Java's default methods in an interface). But using these methods in Kotlin based mapper interfaces will cause a failure with MyBatis because of the underlying Kotlin implementation.
55

6-
This page will show our recommended pattern for using the MyBatis Dynamic SQL with Kotlin. The code shown on this page is from the `src/test/kotlin/examples/kotlin/canonical` directory in this repository. That directory contains a complete example of using this library with Kotlin.
6+
This page will show our recommended pattern for using the MyBatis Dynamic SQL with Kotlin. The code shown on this page is from the `src/test/kotlin/examples/kotlin/mybatis3/canonical` directory in this repository. That directory contains a complete example of using this library with Kotlin.
77

88
All Kotlin support is available in two packages:
99

src/test/kotlin/examples/kotlin/canonical/AddressDynamicSqlSupport.kt renamed to src/test/kotlin/examples/kotlin/mybatis3/canonical/AddressDynamicSqlSupport.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package examples.kotlin.canonical
16+
package examples.kotlin.mybatis3.canonical
1717

1818
import org.mybatis.dynamic.sql.SqlTable
1919
import java.sql.JDBCType

src/test/kotlin/examples/kotlin/canonical/AddressRecord.kt renamed to src/test/kotlin/examples/kotlin/mybatis3/canonical/AddressRecord.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package examples.kotlin.canonical
16+
package examples.kotlin.mybatis3.canonical
1717

1818
data class AddressRecord(var id: Int? = null, var streetAddress: String? = null, var city: String? = null, var state: String? = null)

src/test/kotlin/examples/kotlin/canonical/LastName.kt renamed to src/test/kotlin/examples/kotlin/mybatis3/canonical/LastName.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package examples.kotlin.canonical
16+
package examples.kotlin.mybatis3.canonical
1717

1818
data class LastName(var name: String)

src/test/kotlin/examples/kotlin/canonical/LastNameTypeHandler.kt renamed to src/test/kotlin/examples/kotlin/mybatis3/canonical/LastNameTypeHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package examples.kotlin.canonical
16+
package examples.kotlin.mybatis3.canonical
1717

1818
import org.apache.ibatis.type.JdbcType
1919
import org.apache.ibatis.type.TypeHandler

src/test/kotlin/examples/kotlin/canonical/PersonDynamicSqlSupport.kt renamed to src/test/kotlin/examples/kotlin/mybatis3/canonical/PersonDynamicSqlSupport.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package examples.kotlin.canonical
16+
package examples.kotlin.mybatis3.canonical
1717

1818
import org.mybatis.dynamic.sql.SqlTable
1919
import java.sql.JDBCType
@@ -23,9 +23,9 @@ object PersonDynamicSqlSupport {
2323
object Person : SqlTable("Person") {
2424
val id = column<Int>("id", JDBCType.INTEGER)
2525
val firstName = column<String>("first_name", JDBCType.VARCHAR)
26-
val lastName = column<LastName>("last_name", JDBCType.VARCHAR, "examples.kotlin.canonical.LastNameTypeHandler")
26+
val lastName = column<LastName>("last_name", JDBCType.VARCHAR, "examples.kotlin.mybatis3.canonical.LastNameTypeHandler")
2727
val birthDate = column<Date>("birth_date", JDBCType.DATE)
28-
val employed = column<Boolean>("employed", JDBCType.VARCHAR, "examples.kotlin.canonical.YesNoTypeHandler")
28+
val employed = column<Boolean>("employed", JDBCType.VARCHAR, "examples.kotlin.mybatis3.canonical.YesNoTypeHandler")
2929
val occupation = column<String>("occupation", JDBCType.VARCHAR)
3030
val addressId = column<Int>("address_id", JDBCType.INTEGER)
3131
}

src/test/kotlin/examples/kotlin/canonical/PersonMapper.kt renamed to src/test/kotlin/examples/kotlin/mybatis3/canonical/PersonMapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package examples.kotlin.canonical
16+
package examples.kotlin.mybatis3.canonical
1717

1818
import org.apache.ibatis.annotations.*
1919
import org.apache.ibatis.type.JdbcType

src/test/kotlin/examples/kotlin/canonical/PersonMapperExtensions.kt renamed to src/test/kotlin/examples/kotlin/mybatis3/canonical/PersonMapperExtensions.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package examples.kotlin.canonical
17-
18-
import examples.kotlin.canonical.PersonDynamicSqlSupport.Person
19-
import examples.kotlin.canonical.PersonDynamicSqlSupport.Person.addressId
20-
import examples.kotlin.canonical.PersonDynamicSqlSupport.Person.birthDate
21-
import examples.kotlin.canonical.PersonDynamicSqlSupport.Person.employed
22-
import examples.kotlin.canonical.PersonDynamicSqlSupport.Person.firstName
23-
import examples.kotlin.canonical.PersonDynamicSqlSupport.Person.id
24-
import examples.kotlin.canonical.PersonDynamicSqlSupport.Person.lastName
25-
import examples.kotlin.canonical.PersonDynamicSqlSupport.Person.occupation
16+
package examples.kotlin.mybatis3.canonical
17+
18+
import examples.kotlin.mybatis3.canonical.PersonDynamicSqlSupport.Person
19+
import examples.kotlin.mybatis3.canonical.PersonDynamicSqlSupport.Person.addressId
20+
import examples.kotlin.mybatis3.canonical.PersonDynamicSqlSupport.Person.birthDate
21+
import examples.kotlin.mybatis3.canonical.PersonDynamicSqlSupport.Person.employed
22+
import examples.kotlin.mybatis3.canonical.PersonDynamicSqlSupport.Person.firstName
23+
import examples.kotlin.mybatis3.canonical.PersonDynamicSqlSupport.Person.id
24+
import examples.kotlin.mybatis3.canonical.PersonDynamicSqlSupport.Person.lastName
25+
import examples.kotlin.mybatis3.canonical.PersonDynamicSqlSupport.Person.occupation
2626
import org.mybatis.dynamic.sql.SqlBuilder.isEqualTo
2727
import org.mybatis.dynamic.sql.update.UpdateDSL
2828
import org.mybatis.dynamic.sql.update.UpdateModel

src/test/kotlin/examples/kotlin/canonical/PersonMapperTest.kt renamed to src/test/kotlin/examples/kotlin/mybatis3/canonical/PersonMapperTest.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package examples.kotlin.canonical
16+
package examples.kotlin.mybatis3.canonical
1717

18-
import examples.kotlin.canonical.PersonDynamicSqlSupport.Person.employed
19-
import examples.kotlin.canonical.PersonDynamicSqlSupport.Person.firstName
20-
import examples.kotlin.canonical.PersonDynamicSqlSupport.Person.id
21-
import examples.kotlin.canonical.PersonDynamicSqlSupport.Person.lastName
22-
import examples.kotlin.canonical.PersonDynamicSqlSupport.Person.occupation
18+
import examples.kotlin.mybatis3.canonical.PersonDynamicSqlSupport.Person.employed
19+
import examples.kotlin.mybatis3.canonical.PersonDynamicSqlSupport.Person.firstName
20+
import examples.kotlin.mybatis3.canonical.PersonDynamicSqlSupport.Person.id
21+
import examples.kotlin.mybatis3.canonical.PersonDynamicSqlSupport.Person.lastName
22+
import examples.kotlin.mybatis3.canonical.PersonDynamicSqlSupport.Person.occupation
2323
import org.apache.ibatis.datasource.unpooled.UnpooledDataSource
2424
import org.apache.ibatis.jdbc.ScriptRunner
2525
import org.apache.ibatis.mapping.Environment
@@ -41,7 +41,7 @@ import java.util.*
4141
class PersonMapperTest {
4242
private fun newSession(): SqlSession {
4343
Class.forName(JDBC_DRIVER)
44-
val script = javaClass.getResourceAsStream("/examples/kotlin/CreateSimpleDB.sql")
44+
val script = javaClass.getResourceAsStream("/examples/kotlin/mybatis3/CreateSimpleDB.sql")
4545
DriverManager.getConnection(JDBC_URL, "sa", "").use { connection ->
4646
val sr = ScriptRunner(connection)
4747
sr.setLogWriter(null)

0 commit comments

Comments
 (0)