all of the models right now are heavily annotated ...
# javascript
i
all of the models right now are heavily annotated with backend-stuff (jpa, java validation, spring data, hibernate...)
t
Is it annotations only (jpa, validation)?
👍 1
i
yes - what else could there be? Heres an example model:
Copy code
@EntityListeners(AuditingEntityListener::class)
@Entity
@Inheritance
class Video(
        request: UploadVideoRequest,
        @get: NotBlank
        @NaturalId
        @Column(unique = true)
        val name: String,
        @get: NotNull
        val size: Long = 0,
        @get: NotBlank
        val url: String = ""
) {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    val id: Long = 0

    @Column(nullable = false, updatable = false, columnDefinition = "DATETIME(3)")
    @CreationTimestamp
    lateinit var created: LocalDateTime

    @Column(nullable = false, updatable = true, columnDefinition = "DATETIME(3)")
    @UpdateTimestamp
    lateinit var updated: LocalDateTime

    @ManyToOne
    @JoinColumn(nullable = false, updatable = false, referencedColumnName = "id")
    @CreatedBy
    lateinit var user: User

    @get: NotBlank
    val description: String = request.description
}
t
Actual classes will be better in this case
Which logic will be in common in this case?
Validation?
i
primarily the data structure itsself, not necessarily any logic. if there was a way to get validation to the js side, that would be a bonus.
t
From Spring? 🙂
i
er... no, well - i mean, im not so deep into it, but since these validation annotations are part of the javax.validation package, i thought theyre not necessarily spring specific. But as ive said, they arent my primary concern, i'd be happy if id just get the plain model in a multi-target project or so, but still be able to use it as an @Entity in spring
t
Copy code
// in common
actual class Video {
    val id: Long
    var created: LocalDateTime
    var updated: LocalDateTime
    var user: User
    val description: String = request.description
}

// in jvm
expected class Video ...
👍 1
i
Thanks - sorry, about the stupid question, but im totally new to cross-platform: How can i then put all the annotations in the expected class in jvm on all the fields?
t
Class Video will be the same (only
expected
modifier added)
👍 1
i
thank you - i will get a common module set up, and give that a try!
a
I know it is a while since this was asked. But instead of expect actualing your models, you can expect actualy the annotations used, and provide empty meaningless anotation for kotlin/js. This way, all your models will be in common and you wont have to duplicate the expect actual implementations. Thats what my experience with KMPP has taught me