ActiveJDBC & Kotlin
Dependency Setup
In order to setup ActiveJDBC with Kotlin, add the ActiveJDBC dependency as well as the Kotlin module:
<dependency>
<groupId>org.javalite</groupId>
<artifactId>activejdbc-kt</artifactId>
<version>LATEST_VERSION</version>
</dependency>
Instrumentation
Setting up instrumentation is not any different, please follow instructions here.
Usage
Unlike the Java layer, the Kotlin layer offers two similar ways of setting up a model.
Approach #1
First define an entity
import org.javalite.activejdbc.Model;
import org.javalite.activejdbc.CompanionModel;
class Person():Model() {
open class)
companion object:CompanionModel<Person>(Person:: }
Then use it as in Java
findById(1) val person:Person = Person.
Approach #2 (with English inflections)
The first class is only for the entity itself
import org.javalite.activejdbc.Model;
class Person():Model() open
The second class stands for the table and its name matches English inflection (Person => People)
import org.javalite.activejdbc.CompanionModel;
class People {
open class)
companion object:CompanionModel<Person>(Person:: }
Usage:
findById(1L) val person:Person = People.
How to comment
The comment section below is to discuss documentation on this page.
If you have an issue, or discover bug, please follow instructions on the Support page