Relative Content

Tag Archive for javaspring-bootjpa

New chat message replacing first message instead of adding to end

I’m working on a chat application using Spring Boot, and I’m facing an issue with managing chat messages when the chat reaches its maximum size. My goal is to implement a system where, once the maximum number of messages is reached, the oldest message is removed to make room for a new one. However, I’m encountering a problem where the new message seems to replace the first message in the list instead of being added to the end.

JPA @ElementCollection in @Embeddable

@Entity public class School { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer schoolId; … @ElementCollection @CollectionTable( name = “grades”, joinColumns = @JoinColumn(name = “schoolId”) ) private Set<Grade> grades; } ———————————- @Embeddable public class Grade { private int gradeId @ElementCollection @CollectionTable( name = “Class”, joinColumns = @JoinColumn(name = “gradeId”) ) private Set<Class> classes; } ———————————— @Embeddable public […]