2
Good evening, I’m having a doubt in my studies, I’m doing a project to train knowledge and I came across a problem.
I have a User class:
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String password;
@OneToMany
private List<Service> services = new ArrayList<>();
//get and set
And a Service:
@Entity
public class Service {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String description;
private String userService;
private String password;
My question is, how to search a user’s Services List?
In my view I will have to create an attribute in services and set the id of a user? But this way would not be a "heavy" bank? where I will have to walk all the bank looking for the service that has that "USER_ID"
Thanks for the reply, but when trying to use the user.getServices() I get exceptions.
– H C