[JIRA] (HHH-16735) State of Kotlin's overridden properties is not correctly retrieved when field access is used
by Marko Bekhta (JIRA)
Marko Bekhta ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYjU3Nzk1Yzlh... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16735?atlOrigin=eyJpIjoiYjU3Nz... ) HHH-16735 ( https://hibernate.atlassian.net/browse/HHH-16735?atlOrigin=eyJpIjoiYjU3Nz... ) State of Kotlin's overridden properties is not correctly retrieved when field access is used ( https://hibernate.atlassian.net/browse/HHH-16735?atlOrigin=eyJpIjoiYjU3Nz... )
Change By: Marko Bekhta ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
This came up while looking into [https://github.com/quarkusio/quarkus/issues/33740|https://github.com/quar...]
When there’s an entity hierarchy that relies on the usage of overridden properties, a state built for a subtype ends up having nulls for such a property. For example, with a model
{noformat}@Entity
@Table(name = "shape")
@Inheritance(strategy = InheritanceType.JOINED)
abstract class Shape(
@Id
@JdbcTypeCode(SqlTypes.VARCHAR)
@Column(name = "id", updatable = false, nullable = false, unique = true)
open val id: UUID,
@Length(max = 100)
@Column(name = "name", nullable = false, length = 100)
open var name: String,
)
@Entity
@Table(name = "rectangle")
@PrimaryKeyJoinColumn(name = "shape_id")
data class Rectangle(
override val id: UUID,
override var name: String,
) : Shape(id, name) {noformat}
trying to persist a rectangle entity :
{noformat}val rectangle = Rectangle(
id = UUID.randomUUID(),
name = "Rectangle",
color = Color.Red,
properties = Properties("foo", "bar")
)
em.persist(rectangle){noformat}
will result in [https://github.com/hibernate/hibernate-orm/blob/f22d7e1328c0e063528eb8a16...] returning an array of nulls and failing the operation.
Also, confirmed that switching to {{(a)Access(AccessType.PROPERTY)}} for such properties helps to work around the problem.
Note: issue does not affect 5.6 as, in the end – fields were accessed by a Feild form a subtype rather than a supertype.
( https://hibernate.atlassian.net/browse/HHH-16735#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16735#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100225- sha1:40c4da4 )
2 years, 10 months