[JIRA] (HHH-17026) Object serialization not working with @DiscriminatorColumn and Kotlin
by Marco De Toma (JIRA)
Marco De Toma ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOTJiZWY0ZjFl... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-17026?atlOrigin=eyJpIjoiOTJiZW... ) HHH-17026 ( https://hibernate.atlassian.net/browse/HHH-17026?atlOrigin=eyJpIjoiOTJiZW... ) Object serialization not working with @DiscriminatorColumn and Kotlin ( https://hibernate.atlassian.net/browse/HHH-17026?atlOrigin=eyJpIjoiOTJiZW... )
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 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 defined 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 these 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 CarKotlin WHERE brand =’Audi'{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 example written in Java and Kotlin with Hibernate 5 and 6. The only combination that does NOT work is Koltin Kotlin /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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100233- sha1:8d17c5d )
1 year, 3 months
[JIRA] (HHH-17026) Object serialization not working with @DiscriminatorColumn and Kotlin
by Marco De Toma (JIRA)
Marco De Toma ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNjU2NmQzNWYy... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-17026?atlOrigin=eyJpIjoiNjU2Nm... ) HHH-17026 ( https://hibernate.atlassian.net/browse/HHH-17026?atlOrigin=eyJpIjoiNjU2Nm... ) Object serialization not working with @DiscriminatorColumn and Kotlin ( https://hibernate.atlassian.net/browse/HHH-17026?atlOrigin=eyJpIjoiNjU2Nm... )
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 defined 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 these 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 CarKotlin WHERE brand =’Audi'{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 example written Java 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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100233- sha1:8d17c5d )
1 year, 3 months