Czar
11/17/2019, 9:33 PMprivate lateinit var USER_REPOSITORY: UserRepository
@Configuration
class UserEntityConfiguration(userRepository: UserRepository) {
init {
USER_REPOSITORY = userRepository
}
}
interface UserRepository : JpaRepository<User, Long>
@Entity
class User(override var id: Long?) {
fun save(): User = USER_REPOSITORY.save(this)
}
Too much boilerplate for my taste, but will work.
Alternatively you could make base entity class and write save
once, e.g. using EntityManager
.