I have two domain classes, lets call them Account and AccountInfo. Those are defined like this:
@Entity
@Table(name = "account")
@EqualsAndHashCode(of = {"id", "created", "changed"})
@Getter
@Setter
@AllArgsConstructor
@RequiredArgsConstructor
public class Account {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "account", cascade =
CascadeType.ALL)
@OrderBy("created DESC")
private List<AccountInfo> accountInfos;
When eg. fetching account by id and then calling:
account.getAccountInfos().stream().
map(AccountInfo::getSerialNo).collect(Collectors.toList()));
each serialNo comes out fine. But if I try to:
account.getAccountInfos().stream().
map(AccountInfo::getId).collect(Collectors.toList()));
each id comes out as null.
So why are ids null, are the accountInfos detached right after fetching them or what?