Renzo Schembri (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMzhhZTEwNDE4...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16906?atlOrigin=eyJpIjoiMzhhZT...
) HHH-16906 (
https://hibernate.atlassian.net/browse/HHH-16906?atlOrigin=eyJpIjoiMzhhZT...
) Duplicate column exception when mapping multiple attributes to the same column in an
Embeddable class, irrespective of the insertable and updatable attribute values. (
https://hibernate.atlassian.net/browse/HHH-16906?atlOrigin=eyJpIjoiMzhhZT...
)
Issue Type: Bug Affects Versions: 6.1.7 Assignee: Renzo Schembri (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%...
) Components: hibernate-core Created: 06/Jul/2023 07:25 AM Priority: Major Reporter: Renzo
Schembri (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%...
)
When mapping multiple attributes in an Embeddable class to the same column, the Column
insertable and updatable attributes are not considered, and a MappingException is raised
stating that “Column X is duplicated in mapping for entity Y (use
'@Column(insertable=false, updatable=false)' when mapping multiple properties to
the same column)”.
I am using Hibernate 6.1.7.Final.
A test case was created within the attached pull request which is successful following the
solution provided in the same pull request.
*Example:*
@Entity
@Table(name = "PARTICIPANT")
public class Participant implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
private ParticipantId id;
public ParticipantId getId() {
return id;
}
public void setId(ParticipantId id) {
this.id = id;
}
}
@Embeddable
public class ParticipantId implements Serializable {
private static final long serialVersionUID = 1L;
@Embedded
@AttributeOverrides({
@AttributeOverride( name = "registrationIndex", column = @Column(name
= "REGISTRATION_INDEX")),
@AttributeOverride( name = "registrationDisplay", column =
@Column(name = "REGISTRATION_INDEX", insertable=false, updatable=false)),
})
private ParticipantRegistration registrationNumber;
public ParticipantRegistration getRegistrationNumber() {
return registrationNumber;
}
public void setRegistrationNumber(ParticipantRegistration registrationNumber) {
this.registrationNumber = registrationNumber;
}
}
@Embeddable
public class ParticipantRegistration implements Serializable {
private static final long serialVersionUID = 1L;
private String registrationIndex;
private String registrationDisplay;
public String getRegistrationIndex() {
return registrationIndex;
}
public void setRegistrationIndex(String registrationIndex) {
this.registrationIndex = registrationIndex;
}
public String getRegistrationDisplay() {
return registrationDisplay;
}
public void setRegistrationDisplay(String registrationDisplay) {
this.registrationDisplay = registrationDisplay;
}
}
Unexpected exception thrown: org.hibernate.MappingException: Column
'REGISTRATION_INDEX' is duplicated in mapping for entity
'org.hibernate.orm.test.mapping.Participant' (use
'@Column(insertable=false, updatable=false)' when mapping multiple
properties to the same column)
(
https://hibernate.atlassian.net/browse/HHH-16906#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16906#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#100230- sha1:e339e49 )