Hi everybody,
I’m facing a little problem with JPAContainer.
The matter is that I’ve an entity with a many to many relation with itself:
@Entity
@Table(name = “USERS”)
public class UserApp implements Serializable {
private static final long serialVersionUID = -8195971271846021378L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long userId;
@NotNull @Size(min = 2, max = 24) private String lastName;
@NotNull @Size(min = 2, max = 24) private String firstName;
@NotNull private String email;
@NotNull private String userName;
@NotNull private String password;
@NotNull private String phoneNumber;
@NotNull private String userType;
@JoinTable(name = "professor_student", joinColumns = {
@JoinColumn(name = "professor", referencedColumnName = "userId",
nullable = false) },
inverseJoinColumns = {
@JoinColumn(name = "student", referencedColumnName = "userId",
nullable = false) })
@ManyToMany(cascade = CascadeType.PERSIST)
private List<UserApp> classroom;
…
}
Now, if I wanna to get all users from the table, is easy. But I can figure out what to do to get the students that “belong” to a professor.
Someone could give som advice about it?
Thanks a lot,
Ernesto.