Skip to content

Instantly share code, notes, and snippets.

@mtrojahn
Last active September 14, 2019 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtrojahn/65b5bfcf7e26895edbef7c6113a7b3e6 to your computer and use it in GitHub Desktop.
Save mtrojahn/65b5bfcf7e26895edbef7c6113a7b3e6 to your computer and use it in GitHub Desktop.
@Entity
class Script(
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
var id: Long? = null,
var name: String = "",
var source: String = "",
var description: String = "",
@Version
var version: Long = 0L,
) {
companion object : Finder<Long, Script>(Script::class.java)
}
fun someExamples() {
// lists all scripts
val list = Script.all()
// find a single script by it's name
val script1 = Script.query().where().eq("name", "name of the script").findOne()
// finds the script with id = 1
val script2 = Script.byId(1)
// delete the script with id = 1
Script.deleteById(1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment