【发布时间】:2017-01-13 14:24:15
【问题描述】:
Spring Web 应用程序和 Hibernate 存在问题。它是用 Kotlin 编写的。 我们有一个抽象实体
@Inheritance(strategy = InheritanceType.JOINED)
abstract @Entity class ContactLogEntry protected constructor() {
@GeneratedValue @Id val id: Long = 0
@ManyToOne
@JoinColumn
protected lateinit var _contact: AbstractContact
open val contact: AbstractContact? get() = _contact
@ManyToOne
protected var _user: User? = null
open val user: User? get() = _user
还有一些:
@Entity class MailLogEntry() : ContactLogEntry() {
override var contact: Lead
get() = super.contact as Lead
set(value) {
super._contact = value
}
override var user: Telephonist
get() = super.user as Telephonist
private set(value) {
super._user = value
}
请注意,“Lead”直接继承自“AbstractContact”。问题在于属性contact。 Telephonist 直接从 User 继承的 User 属性工作正常。
我们得到Unable to locate Attribute with the the given name [contact] on this ManagedType (PATH to ContactLogEntry)
我们以前也是这样做的,它在哪里起作用。真的不知道有什么问题。
【问题讨论】:
-
我知道已经 3 年了,但是你有没有成功解决这个问题?我现在偶然发现了这一点。我不能将继承与 TABLE_PER_CLASS 一起使用,因为它需要我在子类中定义 Id..
标签: java spring hibernate spring-mvc kotlin