I have this entity that have these properties
@Entity
@IdClass(LockKeyId::class)
@Table(name = "lock_keys",
uniqueConstraints = [
UniqueConstraint(columnNames = arrayOf("lock_id", "key_id"))
]
)
open class LockKey
{
@Id
@ManyToOne(fetch = FetchType.LAZY, cascade = [CascadeType.ALL])
@JoinColumn(name = "lock_id")
@JsonIgnore
lateinit var lock: Lock
@Id
@ManyToOne(fetch = FetchType.LAZY, cascade = [CascadeType.ALL])
@JoinColumn(name = "key_id")
@JsonIgnore
lateinit var key: Key
}
then in my @IdClass
open class LockKeyId: Serializable {
lateinit var lock: Lock
lateinit var key: Key
override fun equals(other: Any?): Boolean
{
if (other == null) return false
return (other is LockKeyId) && other.lock == this.lock && other.key == this.key
}
}
When I create a new LockKey I get this error
(newLockKey is with type Key)
var lockKey = LockKey()
lockKey.lock = lock
lockKey.key = key
Failed to convert property value of type 'java.util.UUID' to required type 'lock.http.model.Lock' for property 'lock'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.util.UUID' to required type 'lock.http.model.Lock' for property 'lock': no matching editors or conversion strategy found
I'm not sure how to fix this.
Thank you!