Something like this? ``` private lateinit var USER...
# spring
c
Something like this?
Copy code
private 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
.