Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package com.marcelustrojahn.models
import io.ebean.Finder
import java.time.LocalDate
import javax.persistence.*
@Entity
@Inheritance
abstract class BaseEntity(
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
var id: Long? = null,
var name: String = "",
var enabled: Boolean = true,
var addressStreet: String = "",
var addressNumber: Int = 0,
var addressDistrict: String = "",
var addressCity: String = "",
var addressState: String = "",
var addressZip: String = "",
var birth: LocalDate = LocalDate.MIN,
@Version
var version: Long = 0
) {
companion object: Finder<Long, BaseEntity>(BaseEntity::class.java)
override fun toString() = "BaseEntity(id: $id, name: $name)"
}
@Entity
class Person(
var cpf: String? = "",
var rg: String? = ""
) : BaseEntity() {
companion object: Finder<Long, BaseEntity>(BaseEntity::class.java)
override fun toString() = "Person(id: $id, name: $name)"
}
}
@Entity
class Company(
var officialName: String? = "",
var cnpj: String? = "",
var ie: String? = "",
var im: String? = ""
) : BaseEntity() {
companion object: Finder<Long, BaseEntity>(BaseEntity::class.java)
override fun toString() = "Company(id: $id, name: $name)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment