Marko Bekhta (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYjg4YzllMDEw...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16735?atlOrigin=eyJpIjoiYjg4Yz...
) HHH-16735 (
https://hibernate.atlassian.net/browse/HHH-16735?atlOrigin=eyJpIjoiYjg4Yz...
) State of Kotlin's overridden properties is not correctly retrieved when field access
is used (
https://hibernate.atlassian.net/browse/HHH-16735?atlOrigin=eyJpIjoiYjg4Yz...
)
Issue Type: Bug Assignee: Unassigned Created: 01/Jun/2023 03:31 AM Priority: Minor
Reporter: Marko Bekhta (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
This came up while looking into
https://github.com/quarkusio/quarkus/issues/33740
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
@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)
trying to persist a rectangle entity :
val rectangle = Rectangle(
id = UUID.randomUUID(),
name = "Rectangle",
color = Color.Red,
properties = Properties("foo", "bar")
)
em.persist(rectangle)
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 @Access(AccessType.PROPERTY) for such properties helps
to work around the problem.
(
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=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100225- sha1:40c4da4 )