Chris Cobham (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMmRmMWViNDIz...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16698?atlOrigin=eyJpIjoiMmRmMW...
) HHH-16698 (
https://hibernate.atlassian.net/browse/HHH-16698?atlOrigin=eyJpIjoiMmRmMW...
) @Any Polymorphic Association Ignores @Column Insertable/Updatable Attributes (
https://hibernate.atlassian.net/browse/HHH-16698?atlOrigin=eyJpIjoiMmRmMW...
)
Issue Type: Bug Affects Versions: 6.2.0, 6.2.1, 6.2.2, 6.2.3 Assignee: Unassigned
Components: hibernate-core Created: 25/May/2023 11:18 AM Priority: Major Reporter: Chris
Cobham (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3...
)
Starting in Hibernate ORM 6.2, polymorphic associations using @Any raise
MappingException}}s if either the key or discriminator column is mapped to another
(mutable) attribute in the owning entity. This prevents read-only {{@Any associations in
which the duplicated column mappings cannot be defined with @Column(insertable=false,
updatable=false)
*Solution*
package org.hibernate.mapping;
...
public class Any extends SimpleValue {
...
public void setDiscriminator(BasicValue discriminatorDescriptor) {
this.discriminatorDescriptor = discriminatorDescriptor;
if ( discriminatorDescriptor.getColumn() instanceof Column ) {
// Current: justAddColumn( (Column) discriminatorDescriptor.getColumn() );
justAddColumn(
(Column) discriminatorDescriptor.getColumn(),
// Pass insertable/updatable from discriminatorDescriptor
discriminatorDescriptor.isColumnInsertable(0),
discriminatorDescriptor.isColumnUpdateable(0)
);
}
else {
justAddFormula( (Formula) discriminatorDescriptor.getColumn() );
}
}
...
public void setKey(BasicValue keyDescriptor) {
this.keyDescriptor = keyDescriptor;
if ( keyDescriptor.getColumn() instanceof Column ) {
// Current: justAddColumn( (Column) keyDescriptor.getColumn() );
justAddColumn(
(Column) keyDescriptor.getColumn(),
// Pass insertable/updatable from keyDescriptor
keyDescriptor.isColumnInsertable(0),
keyDescriptor.isColumnUpdateable(0)
);
}
else {
justAddFormula( (Formula) keyDescriptor.getColumn() );
}
}
}
(
https://hibernate.atlassian.net/browse/HHH-16698#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16698#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:0428b75 )