I migrated Spring Boot 2 to Spring Boot 3. During Boot time I get this error:
Table 1:
import jakarta.persistence.Column;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.MapsId;
import jakarta.persistence.Table;
@Entity
@Table(name = "corporate_account_linkages")
public class CorporateAccountLinkage {
@EmbeddedId
private CorporateAccountLinkageKey corporateAccountLinkageKey;
@ManyToOne
@MapsId("corporate_account_id")
@JoinColumn(name = "corporate_account_id")
private CorporateAccount corporateAccountId;
@ManyToOne
@MapsId("linked_corporate_account_id")
@JoinColumn(name = "linked_corporate_account_id")
private CorporateAccount linkedCorporateAccountId;
Table 2:
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
@Embeddable
public class CorporateAccountLinkageKey implements Serializable {
@Column(name = "corporate_account_id", nullable = false)
private Long corporateAccountId;
@Column(name = "linked_corporate_account_id", nullable = false)
private Long linkedCorporateAccountId;
I get error:
Caused by: org.hibernate.AnnotationException: Identifier field 'linked_corporate_account_id' named in '@MapsId' does not exist in entity 'com.platform.entity.CorporateAccountLinkage'
...
Caused by: org.hibernate.MappingException: component: com.platform.entity.orporateAccountLinkageKey property not found: linked_corporate_account_id
at org.hibernate.mapping.Component.getProperty(Component.java:506) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
at org.hibernate.boot.model.internal.AnnotatedJoinColumns.resolveMapsId(AnnotatedJoinColumns.java:222) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
What are the possible options to migrate this code for latest Spring Boot?
Should I replace @MapsId
with something else or add @MapsId
into table CorporateAccountLinkageKey
? Or there is some other solution?
1