Seong Lee (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%...
) *commented* on HHH-16934 (
https://hibernate.atlassian.net/browse/HHH-16934?atlOrigin=eyJpIjoiYTQ1M2...
)
Re: Fetching multiple fields of the same base class with InheritanceType.SINGLE_TABLE
throws PropertyAccessException (
https://hibernate.atlassian.net/browse/HHH-16934?atlOrigin=eyJpIjoiYTQ1M2...
)
Hello, I am seeing this exact same error when using a InheritanceType.JOINED type on the
parent. This was working fine on SpringBoot 3.0.6
I am on SpringBoot 3.1.2 , which uses Hibernate 6.2.6.Final. I’ve also tried forcing the
6.3.0.CR1 version and still see the error. This is written in Kotlin.
@Entity
@Table(name = "Resource")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "RESOURCE_TYPE_CD", discriminatorType =
DiscriminatorType.INTEGER, columnDefinition = "INT")
abstract class Resource(
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"RESOURCE_ID_SEQ")
@SequenceGenerator(name = "RESOURCE_ID_SEQ", sequenceName =
"RESOURCE_ID_SEQ", allocationSize = 1)
override var id: Long? = null,
@Column(name = "RESOURCE_TYPE_CD", insertable = false, updatable = false)
open var resourceType: ResourceType
): MutableAuditableBaseJpa<Long>() { ... }
@Entity
@Table(name = "RESOURCE_FUTURE_ROLE")
@DiscriminatorValue("1")
class FutureRole(
...
): Resource(null, ResourceType.FUTURE_ROLE) { ... }
@Entity
@Table(name = "RESOURCE_CURRENT_ROLE")
@DiscriminatorValue("2")
class CurrentRole(
...
): Resource(null, ResourceType.CURRENT_ROLE) { ... }
@Entity
@Table(name = "RECORD")
open class Record(
@Column(name = "RESOURCE_ID") override var resourceId: Long,
...
): MutableAuditableBaseJpa<Long>() {
@OneToOne
@NotFound(action = NotFoundAction.IGNORE)
@JoinColumn(name = "RESOURCE_ID", insertable = false, updatable = false)
open var futureRole: FutureRole? = null
@OneToOne
@NotFound(action = NotFoundAction.IGNORE)
@JoinColumn(name = "RESOURCE_ID", insertable = false, updatable = false)
open var employee: CurrentRole? = null
}
Caused by: org.hibernate.PropertyAccessException: Could not set value of type
[com.hidden.CurrentRole]: 'com.hidden.Record.futureRole' (setter)
at org.hibernate.property.access.spi.SetterFieldImpl.set(SetterFieldImpl.java:88)
at
org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:4360)
at
org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.initializeEntityInstance(AbstractEntityInitializer.java:837)
at
org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.initializeEntity(AbstractEntityInitializer.java:797)
at
org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.initializeInstance(AbstractEntityInitializer.java:783)
at
org.hibernate.sql.results.internal.InitializersList.initializeInstance(InitializersList.java:71)
at
org.hibernate.sql.results.internal.StandardRowReader.coordinateInitializers(StandardRowReader.java:109)
at
org.hibernate.sql.results.internal.StandardRowReader.readRow(StandardRowReader.java:86)
at
org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:201)
at
org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:33)
at
org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.doExecuteQuery(JdbcSelectExecutorStandardImpl.java:361)
at
org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.executeQuery(JdbcSelectExecutorStandardImpl.java:168)
at
org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.list(JdbcSelectExecutorStandardImpl.java:93)
at org.hibernate.sql.exec.spi.JdbcSelectExecutor.list(JdbcSelectExecutor.java:31)
at
org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.lambda$new$0(ConcreteSqmSelectQueryPlan.java:109)
at
org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.withCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:305)
at
org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.performList(ConcreteSqmSelectQueryPlan.java:246)
at org.hibernate.query.sqm.internal.QuerySqmImpl.doList(QuerySqmImpl.java:509)
at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:427)
at
org.hibernate.query.spi.AbstractSelectionQuery.getSingleResult(AbstractSelectionQuery.java:559)
Note: I understand @DiscriminatorColumn is unnecessary for a Joined Inheritance, but this
was existing logic I have yet to change.
(
https://hibernate.atlassian.net/browse/HHH-16934#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16934#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#100233- sha1:7fb7fe8 )