I'm having a problem with trying to display the contents of a list.
Every venue has an owner so we have a many to one relationship
Code:
private UserEnt owner;
@ManyToOne
@JoinColumn
@NotNull
public UserEnt getOwner() {
return owner;
}
public VenueEnt(...,UserEnt owner, ...) {
...
this.owner = owner;
...
}
And every owner can have many venues so we have a 1 to many relationship.
Code:
private Set<VenueEnt> ownedVenues = new HashSet<VenueEnt>();
@OneToMany (cascade = {CascadeType.PERSIST, CascadeType.MERGE }, mappedBy = "owner", fetch=FetchType.EAGER)
@org.hibernate.annotations.Cascade(value = org.hibernate.annotations.CascadeType.SAVE_UPDATE)
public Set<VenueEnt> getOwnedVenues() {
return ownedVenues;
}
Why is that when i create a venue and in the constructor i add the user as the owner (and it correctly reflects in the DB), when i do a user.getOwnedVenues() i do not get correct results? Is a particular case, a user is the owner of 3 venues, but on call the set size is 0.
Thanks!