We are experiencing issues after upgrading the Spring Boot version to 3.2.3 or later.
We have an N x N mapping between Student and Course. We use EmbeddedId to handle the mapping.
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Validated
@Entity
@Table(name = "STUDENT", schema = "COLLEGE_OWNER")
public class Student {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STUDENT_OID")
@SequenceGenerator(name = "SEQ_ADESAO_OID", sequenceName = "SEQ_STUDENT_OID", allocationSize = 1, schema = "COLLEGE_OWNER")
@Column(name = "OID_STUDENT")
private Long oidStudent;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "student")
private Set<StudentCourse> studentCourseList;
@Size(max = 100, message = "The nomeSolicitante field must contain a maximum of 100 characters.")
@NotBlank(message = "The nomeSolicitante field cannot be blank or null.")
@Column(name = "STUDENT_NAME", nullable = false, length = 100)
private String studentName;
}
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "COURSE", schema = "SPIAPIPIX_OWNER")
public class Course {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_COURSE_OID")
@SequenceGenerator(name = "SEQ_COURSE_OID", sequenceName = "SEQ_COURSE_OID", allocationSize = 1, schema = "COLLEGE_OWNER")
@Column(name = "OID_COURSE")
private Long oidCourse;
@Size(max = 100, message = "The courseName field must contain a maximum of 100 characters")
@Column(name = "COURSE_NAME", length = 100)
private String courseName;
}
The
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Validated
@Entity
@Table(name = "STUDENT_COURSE", schema = "COLLEGE_OWNER")
public class StudentCourse {
@EmbeddedId
@Valid
@NotNull(message = "The fiield studentCourseId can't be null")
@Builder.Default
private StudentCourseId studentCourseId = new StudentCourseId();
@ManyToOne(fetch = FetchType.LAZY)
@MapsId("oidStudent")
@JoinColumn(name = "OID_STUDENT")
private Student student;
@ManyToOne(fetch = FetchType.LAZY)
@MapsId("oidCourse")
@JoinColumn(name = "OID_COURSE")
private Course course;
}
@Embeddable
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
public class StudentCourseId implements Serializable {
@Serial
private static final long serialVersionUID = 1;
@NotNull(message = "O campo oidAdesao nao pode ser nulo")
@Column(name = "OID_STUDENT")
private Long oidStudent;
@NotNull(message = "O campo oidEmpresaIntegradora nao pode ser nulo")
@Column(name = "OID_COURSE")
private Long oidCourse;
}
The problem occurs when performing any operation that retrieves information from the database for the Embeddable class StudentCourseId. The information is not loaded, and the object has the fields oidStudent and oidCourse set to null. In version 3.2.2 and earlier, we did not have this problem.
We have identified that the issue occurs starting from version 3.2.3. We have already tested it with the latest version 3.3.X
Luis Henrique Ferreira Bottino is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.