2016-04-21 57 views
1
@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"如何初始化註釋的數組屬性在科特林

回答

5

cascade註解屬性接受的CascadeType數組因此你需要在你@ManyToOne用法更改爲:

@ManyToOne(cascade = arrayOf(javax.persistence.CascadeType.DETACH))