Hi
@JmixEntity
@Table(name = "PARENT", indexes = [
Index(name = "IDX_PARENT_CHILD_REFERENCE", columnList = "CHILD_REFERENCE_ID")
])
@Entity
open class Parent {
@JmixGeneratedValue
@Column(name = "ID", nullable = false)
@Id
var id: UUID? = null
@JoinColumn(name = "CHILD_REFERENCE_ID")
@OneToOne(fetch = FetchType.LAZY)
var childReference: BaseChild? = null
}
---
@JmixEntity
@Table(name = "BASE_CHILD")
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
open class BaseChild {
@JmixGeneratedValue
@Column(name = "ID", nullable = false)
@Id
var id: UUID? = null
@NotNull
@OneToOne(fetch = FetchType.LAZY, mappedBy = "childReference", optional = false)
var parent: Parent? = null
@InstanceName
fun getInstanceName(): String = "foo"
}
---
@JmixEntity
@Table(name = "CHILD_A")
@Entity
open class ChildA : BaseChild() {
@Column(name = "A")
var a: String? = null
}
I have have an issue on a property with an inheritance. In the ParentBrowser screen the childReference is always null. childReference is in the fetch plan. it is not null in Database. but in the ParentDc it is null in every item.
I made a little test project that reproduce this issue.
(BaseChildBrowse shows an empty table even when we have data in the table)
@Subscribe(id = "parentsDc", target = Target.DATA_CONTAINER)
private fun onParentsDcCollectionChange(event: CollectionContainer.CollectionChangeEvent<Parent>) {
// we can see that childReference is not null in DB.
println("in database: " + dataManager.load(Parent::class.java).all().list().first().childReference?.getInstanceName())
// but the screen fails to load childReference despite that it's in the fetch plan
println("in dataContainer: " + parentsDc.items.first().childReference?.getInstanceName())
}
bugInheritancePerTable_.zip (415.3 KB)