In the codes below, I’m trying to create a ManyToOne relationship between two entities using Hibernate but I get the error that “ManyToOne attribute type should not be SimpleObjectProperty”. I need to keep the SimpleObject property because of Javafx binding.
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "driverId")
@Convert(converter = SimpleUserConvertor::class)
val driverProperty = SimpleObjectProperty<User>()
However, if I do this:
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "driverId")
var driver: User? = null
Then the relationship get created but now I lose the SimpleObjectProperty so I can no longer use Javafx binding, but I need it.
Then if I try another approach like this,
val driverProperty = SimpleObjectProperty<User>()
var driver: User?
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "driverId")
get() {
return driverProperty.get()
}
set(value) {
driverProperty.set(value)
}
then, Hibernate doesn’t create the driverId column.