Skip to content
Advertisement

Tag: many-to-many

Spring data JPA: Three entities ManyToMany relations, query duplicate result with findById

User.java UserRole.java RolePermission.java JDK:17 SpringBoot:2.7.4 findById and findBy are also generate different structure SQL. findById uses left outer Join. findByName uses subquery. the user only have one role, the role have three permissions. if use findByUsername It will return the user info correctly. If I use findById, the same role repeat three times。 } code : https://github.com/shuanshuan/demo-questions Answer While fetching

Joint table in many-to-many is not updating

I have a relation N:M between 2 entities, “Alumno” and “Curso”: Alumno Curso On AlumnoService I have the following two methods: According to the printed lines, all the data is fetch correctly, and on Postman I get a correct answer: This is the AlumnoController: However, upon inspecting the database, the shared table is empty: Any idea on what the issue

Which collections are supported by Hibernate @ManyToMany annotation

I used @ManyToMany annotation on a Set and it worked fine. When I used ArrayList instead of Set it throws exception: org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: com.kaushik.winnersoft.data.Student.enrolledCourses Is ArrayList not supported? Which all collection are supported by @ManyToMany annotation? Answer The supported interfaces are: You get the exception because you have

JOOQ pojos with one-to-many and many-to-many relations

I am struggling to understand how to handle pojos with one-to-many and many-to-many relationships with JOOQ. I store locations that are created by players (one-to-many relation). A location can hold multiple additional players who may visit it (many-to-many). The database layout comes down to the following: Within my java application, all these informations are stored within one pojo. Note that

Advertisement