Alex Nistico ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZGM0YjBlODRl... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16490?atlOrigin=eyJpIjoiZGM0Yj... ) HHH-16490 ( https://hibernate.atlassian.net/browse/HHH-16490?atlOrigin=eyJpIjoiZGM0Yj... ) The discriminator type mapper overrides any custom type specfied for a field mapped over the same column ( https://hibernate.atlassian.net/browse/HHH-16490?atlOrigin=eyJpIjoiZGM0Yj... )
Change By: Alex Nistico ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
If an entity maps a field and the discriminator on the same column, the entity persister tries to use the same value persister for both the discriminator and the field, which causes problems if the field is mapped using a different type.
A simplified example of the situation is:
{noformat}@Entity
@Inheritance(strategy = SINGLE_TABLE)
@DiscriminatorColumn(name = "code")
public abstract class MarketValue {
@Id
@GeneratedValue(strategy = AUTO)
private final Long id;
@Column(nullable = false, insertable = false, updatable = false)
private final MarketId code;
....
}{noformat}
Where MarketId has a JavaType registered in the type contributions.
If I try do read an instance from the database I get the following exception:
{noformat}Caused by: java.lang.IllegalArgumentException: Can not set final com.example.demo.model.MarketId field com.example.demo.model.MarketValue.code to java.lang.String
at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) ~[na:na]
at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) ~[na:na]
at java.base/jdk.internal.reflect.UnsafeQualifiedObjectFieldAccessorImpl.set(UnsafeQualifiedObjectFieldAccessorImpl.java:83) ~[na:na]
at java.base/java.lang.reflect.Field.set(Field.java:799) ~[na:na]
at org.hibernate.property.access.spi.SetterFieldImpl.set(SetterFieldImpl.java:53) ~[hibernate-core-6.1.7.Final.jar:6.1.7.Final]
... 103 common frames omitted{noformat}
Attached is an example project illustrating the problem.
A work around for this is to register an attribute converter for the field:
{noformat}@Entity
@Inheritance(strategy = SINGLE_TABLE)
@DiscriminatorColumn(name = "code")
public abstract class MarketValue {
@Id
@GeneratedValue(strategy = AUTO)
private final Long id;
@Column(nullable = false, insertable = false, updatable = false)
@Convert(converter = MarketIdJavaType.class)
private final MarketId code;
....
}{noformat}
( https://hibernate.atlassian.net/browse/HHH-16490#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16490#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#100222- sha1:c08beee )
Alex Nistico ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiM2FlMDdmZDEy... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16490?atlOrigin=eyJpIjoiM2FlMD... ) HHH-16490 ( https://hibernate.atlassian.net/browse/HHH-16490?atlOrigin=eyJpIjoiM2FlMD... ) The discriminator type mapper overrides any custom type specfied for a field mapped over the same column ( https://hibernate.atlassian.net/browse/HHH-16490?atlOrigin=eyJpIjoiM2FlMD... )
Change By: Alex Nistico ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
If an entity maps a field and the discriminator on the same column, the entity persister tries to use the same value persister for both the discriminator and the field, which causes problems if the field is mapped using a different type.
A simplified example of the situation is:
{noformat}@Entity
@Inheritance(strategy = SINGLE_TABLE)
@DiscriminatorColumn(name = "code")
public abstract class MarketValue {
@Id
@GeneratedValue(strategy = AUTO)
private final Long id;
@Column(nullable = false, insertable = false, updatable = false)
private final MarketId code;
....
}{noformat}
Where MarketId has a JavaType registered in the type contributions.
If I try do read an instance from the database I get the following exception:
{noformat}Caused by: java.lang.IllegalArgumentException: Can not set final com.example.demo.model.MarketId field com.example.demo.model.MarketValue.code to java.lang.String
at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) ~[na:na]
at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) ~[na:na]
at java.base/jdk.internal.reflect.UnsafeQualifiedObjectFieldAccessorImpl.set(UnsafeQualifiedObjectFieldAccessorImpl.java:83) ~[na:na]
at java.base/java.lang.reflect.Field.set(Field.java:799) ~[na:na]
at org.hibernate.property.access.spi.SetterFieldImpl.set(SetterFieldImpl.java:53) ~[hibernate-core-6.1.7.Final.jar:6.1.7.Final]
... 103 common frames omitted{noformat}
Attached is an example project illustrating the problem.
A work around for this is to register an attribute converter for the field:
{noformat}@Entity
@Inheritance(strategy = SINGLE_TABLE)
@DiscriminatorColumn(name = "code")
public abstract class MarketValue {
@Id
@GeneratedValue(strategy = AUTO)
private final Long id;
@Column(nullable = false, insertable = false, updatable = false)
@Convert(converter = MarketIdJavaType.class)
private final MarketId code;
....
}{noformat}
( https://hibernate.atlassian.net/browse/HHH-16490#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16490#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#100222- sha1:c08beee )
Alex Nistico ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOWMwZTdhNzcw... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16490?atlOrigin=eyJpIjoiOWMwZT... ) HHH-16490 ( https://hibernate.atlassian.net/browse/HHH-16490?atlOrigin=eyJpIjoiOWMwZT... ) The discriminator type mapper overrides any custom type specfied for a field mapped over the same column ( https://hibernate.atlassian.net/browse/HHH-16490?atlOrigin=eyJpIjoiOWMwZT... )
Change By: Alex Nistico ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
If an entity maps a field and the discriminator on the same column, the entity persister tries to use the same value persister for both the discriminator and the field, which causes problems if the field is mapped using a different type.
A simplified example of the situation is:
{noformat}@Entity
@Inheritance(strategy = SINGLE_TABLE)
@DiscriminatorColumn(name = "code")
public abstract class MarketValue {
@Id
@GeneratedValue(strategy = AUTO)
private final Long id;
@Column(nullable = false, insertable = false, updatable = false)
private final MarketId code;
....
}{noformat}
Where MarketId has a JavaType registered in the type contributions.
If I try do read an instance from the database I get the following exception:
{noformat}Caused by: java.lang.IllegalArgumentException: Can not set final com.example.demo.model.MarketId field com.example.demo.model.MarketValue.code to java.lang.String
at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) ~[na:na]
at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) ~[na:na]
at java.base/jdk.internal.reflect.UnsafeQualifiedObjectFieldAccessorImpl.set(UnsafeQualifiedObjectFieldAccessorImpl.java:83) ~[na:na]
at java.base/java.lang.reflect.Field.set(Field.java:799) ~[na:na]
at org.hibernate.property.access.spi.SetterFieldImpl.set(SetterFieldImpl.java:53) ~[hibernate-core-6.1.7.Final.jar:6.1.7.Final]
... 103 common frames omitted{noformat}
Attached is an example project illustrating the problem.
A work around for this is to register an attribute converter for the field:
{noformat}@Entity
@Inheritance(strategy = SINGLE_TABLE)
@DiscriminatorColumn(name = "code")
public abstract class MarketValue {
@Id
@GeneratedValue(strategy = AUTO)
private final Long id;
@Column(nullable = false, insertable = false, updatable = false)
@Convert(converter = MarketIdJavaType.class)
private final MarketId code;
....
}{noformat}
( https://hibernate.atlassian.net/browse/HHH-16490#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16490#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#100222- sha1:c08beee )