Hello everyone! I am beginning to start a new proj...
# server
d
Hello everyone! I am beginning to start a new project with Kotlin 1.2.71 + Spring Boot 2.0.6 with JPA. I have written in Java before this time and I have questions about Kotlin (compile time and runtime features). There are features those surprised me a little bit. I enable plugins for JPA (you know pure Kotlin couldn’t work with old frameworks for Java like Hibernate or Spring)
Copy code
id 'org.jetbrains.kotlin.plugin.allopen' version '1.2.71'
id 'org.jetbrains.kotlin.plugin.noarg' version '1.2.71'
id 'org.jetbrains.kotlin.plugin.spring' version '1.2.71'
id 'org.jetbrains.kotlin.plugin.jpa' version '1.2.71'
Then I created entity instance and saved it in RDBMS
Copy code
@Entity
data class User(
        @Id
        @SequenceGenerator(name = "users_id_generator", sequenceName = "users_id_seq")
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "users_id_generator")
        val id: Long = 0,
        val userId: String
}
Copy code
@Test
    fun `find by id and user id should return the saved User`() {
        val user = createUser(1)
        assertThat(user.id).isZero()

        val savedUser = userRepository.saveAndFlush(user)
        assertThat(user.id).isPositive()
        // ...
   }

    private fun createUser(userId: Long): User = User(userId = userId.toString())