我想用kotlin语言在jpa hibernate实体类中建立继承。baseentity和derivedentity是jpa实体,其中derivedentity扩展了baseentity。
@Entity
@Table(name = "base_entity")
@Inheritance(strategy = InheritanceType.JOINED)
open class BaseEntity(
@Id // sequence generator left out for brevity
open var id: Int = 0,
@Column(name = "uuid")
open val uuid: UUID,
@ElementCollection
@CollectionTable(name = "collection_list", joinColumns = [JoinColumn(name = "id")])
@Column(name = "collection_name")
open val collections: List<String> = emptyList(),
)
和
@Entity
@Table(name = "derived_entity")
class DerivedEntity(
@Column(name = "index_val")
val indexVal: String = "",
// (location- "A") define base param here?
) : BaseEntity(
// (location "B" ) pass params for base entity
)
我想用 @Inheritance(strategy = InheritanceType.JOINED)
.
我想要的是derviedentity应该扩展baseentity,我的问题是:
我应该在derivedentity中定义baseentity的属性吗(位置-a)
我应该如何在派生类扩展的baseentity构造函数中传递baseentity属性/参数(在位置-b)
我是kotlin的新手,找不到太多关于kotlin jpa继承组合的阅读资料。有什么线索请帮忙!
暂无答案!
目前还没有任何答案,快来回答吧!