0

Greeting to all,

As I'm learning Java, JDBC and MySQL I reach one point where I would like to perform the following

I have 2 entites

    class User {
private Long id;
private String username; 
...
...
private Set<Team> teams;

Constructors /
Getter/Setter

Second Entity

    class Team {
private Long id;
private String name;
private Set<Users> users

Constructors/Getter/Setters 

in my mysql there are 3 tables corresponding to User/Team and hybrid table where is the relationship between them users_teams holding user_id and team_id

My question is is there is a way when I call a sql query to select 1 team and all users in that particular team and get the info with ResultSet and build the Team object with the set of the users

or I need to do couple of sql queries to get the info separately and build the object later ?

  • The answer is: obviously yes. To learn basics of SQL you can refer for example to chapter 3.2 of this tutorial: https://www3.ntu.edu.sg/home/ehchua/programming/sql/MySQL_Beginner.html#zz-3.2 I propose to read not only this single chapter, but whole the tutorial, it is very suitable for understanding. – Daniel Zin May 20 '21 at 11:34
  • @DanielZ. Thank you! I will go through the tutorial! – Svetlyo Stoyanov May 20 '21 at 11:56
  • @DanielZ. thank the tutorial was very helpful I was able to answer my question and to find the solution to my problem, GROUP_CONCAT help me to extract the information which I need to build my objects – Svetlyo Stoyanov May 21 '21 at 14:00

0 Answers0