Marco De Toma (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZGNlNmQxYzhj...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-17026?atlOrigin=eyJpIjoiZGNlNm...
) HHH-17026 (
https://hibernate.atlassian.net/browse/HHH-17026?atlOrigin=eyJpIjoiZGNlNm...
) Object serialization not working with @DiscriminatorColumn and Kotlin (
https://hibernate.atlassian.net/browse/HHH-17026?atlOrigin=eyJpIjoiZGNlNm...
)
Change By: Marco De Toma (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
First of all, I apologise in advance if this is the not right place to report this bug.
I encounter this error after upgrading to hibernate 6 but, based on my findings, it occurs
only with Kotlin (it works properly in Java).
I decided to open a ticket here because it works properly with Hibernate version 5.x
h4. Context
I have this table
{code:sql}CREATE TABLE vehicles (
id uuid DEFAULT random_uuid(),
vehicle_type varchar(255) not null,
brand varchar(255) not null
);
insert into vehicles (vehicle_type, brand) values ('CAR', 'Audi'){code}
and defined two entities with {{SINGLE_TABLE}} hierarchy:
{noformat}@Entity
@Table(name = "vehicles")
@DiscriminatorColumn(name = "vehicle_type", discriminatorType =
DiscriminatorType.STRING)
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
abstract class VehicleKotlin(
@Id
open var id: UUID,
@Column(name = "brand")
open var brand: String,
)
@Entity
@DiscriminatorValue("CAR")
data class CarKotlin(
@Id override var id: UUID,
override var brand: String,
) : VehicleKotlin(
id = id,
brand = brand,
){noformat}
h4. Error
When I try to query the database
{code:sql}FROM VehicleKotlin CarKotlin WHERE brand =’s{code}
it seems like that the serialization does not work work properly.
As you can see in the attachment, {{id}} and {{brand}} are null while
{{VehicleKotlin.id`}} and`VehicleKotlin.brand` are set with the right values (but they
don’t even exist in the model).
In this demo
([
https://github.com/detomarco/hibernate-bug-report|https://github.com/deto...]
) you can find the same code work properly in example written Java but not in Koltin and
Kotlin with Hibernate 5 and 6. The only combination that does NOT work is Koltin/Hibernate
6
Thank you in advance
(
https://hibernate.atlassian.net/browse/HHH-17026#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-17026#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:8d17c5d )