Define lazy and eager fetching explicit

This commit is contained in:
Marcel Schwarz 2020-05-13 13:42:43 +02:00
parent 8dc4604f61
commit 4c05c668cb
2 changed files with 3 additions and 3 deletions

View File

@ -18,8 +18,8 @@ public class TimeRecord {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@OneToOne
private TimetrackAccount account; // TimetrackAccount ID (Lazy)
@OneToOne(fetch = FetchType.LAZY)
private TimetrackAccount account;
private Date startdate;
private Date enddate;
private Duration time;

View File

@ -30,7 +30,7 @@ public class TimetrackUser {
private String lastname;
@OneToOne
@OneToOne(fetch = FetchType.EAGER)
private Role role;
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.ALL)