i upgraded to spring boot 3.2.1 (that use hibernate 6.4.1)
I get this error since this upgrade when i try to boot application
Join column 'query_type_id' on collection property 'com.acme.demo.common.QueryType.queryStatus' must be defined with the same insertable and updatable attributes
@Data
@Entity
@Table
public class QueryType {
@Id
@SequenceGenerator
@GeneratedValue
private Long QueryTypeId;
private String code;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "queryType")
private Set<Query> queries = new HashSet<>(0);
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "QUERY_STATUS_TYPE", schema = "", joinColumns = { @JoinColumn(name = "QUERY_TYPE_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "QUERY_STATUS_ID", nullable = false, updatable = false) })
private Set<QueryStatus> queryStatus = new HashSet<>(0);
}
@Data
@Entity
@Table
@DiscriminatorColumn(name = "QUERYTYPE_CODE", discriminatorType = DiscriminatorType.STRING)
public abstract class QueryStatus {
@Id
@SequenceGenerator
@GeneratedValue
@NotNull
private Long queryStatusId;
private String code;
private String description;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "queryStatus")
private Set<Query> queries = new HashSet<>(0);
}
i have some class who extends QueryStatus
I just don't understand why i get this error suddendly
that worked fine with spring boot 3.2.0 (that use hibernate 6.3.1)
You can probably remove the updatable
since in previous versions it wouldn't prevent the adding or removing of members of the relationship.
joinColumns = { @JoinColumn(name = "QUERY_TYPE_ID", nullable = false ) }, inverseJoinColumns = { @JoinColumn(name = "QUERY_STATUS_ID", nullable = false)
If your intention is to make the relationship readonly, than you need to add both insertable=false
and updatable=false
joinColumns = { @JoinColumn(name = "QUERY_TYPE_ID", nullable = false, insertable=false, updatable=false) }, inverseJoinColumns = { @JoinColumn(name = "QUERY_STATUS_ID", nullable = false, insertable=false, updatable=false)
This is based on the responses from the related Hibernate ticket https://hibernate.atlassian.net/browse/HHH-17586
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With