如何在Kotlin中初始化注释的数组属性
@Entity @Table(name = "t_payment") data class PaymentEntity( @ManyToOne(cascade = CascadeType.DETACH) @JoinColumn(name = "user_id", nullable = false) var user: User? = null) : Serializable { }
作为编译错误的结果: "Type mismatch"
cascade
注释属性接受一个CascadeType
数组,因此您需要将您的@ManyToOne
用法更改为:
@ManyToOne(cascade = arrayOf(javax.persistence.CascadeType.DETACH))