I have the following class:
@Entity
public class TestContentElementResponse
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
protected Long id;
@OneToMany(mappedBy = "testContentElementResponse", cascade = CascadeType.ALL, orphanRemoval = false)
private Set<ResponseAttribute> associatedResponseAttributes = new HashSet<ResponseAttribute>();
@ManyToOne
@JoinColumn(name = "userfulltestId", referencedColumnName = "id", nullable = false)
private UserFullTest userFullTest;
@ManyToOne
@JoinColumn(name = "testContentElementId", referencedColumnName = "id", nullable = false)
private TestContentElement testContentElement;
@OneToOne(cascade = CascadeType.ALL)
private TestContentElementScore testContentElementScore;
@ManyToOne
@JoinColumn(name = "userId", referencedColumnName = "id", nullable = false)
private User user;
TestContentElementResponse.class represents one user response in a test. One test can be 30 questions, so 30 responses per user.
Now I want to call ALL TestContentElementResponse for ONE user (common id is UserFullTestId) and ALL ResponseAttributes for each TestContentElementResponse.
I can do this with a criteria query, but I am not sure whether to use a SELECT or JOIN FetchMode. I do understand that JOIN will make one big call to the database and SELECT will make many rapid calls. However, I do not know what factors help me decide which method is optimum.
(Of course, I will run tests, but that will only answer which method is optimum, it won't explain why)
Help would be greatly appreciated