I know that may that question has been asked before, but the difference for my question is that I am using extended PersistenceUnit and also I am not the one who manages the transaction as the server is responsible for managing it.
BTW I am using JPA(2.1) with hibernate(4.3.10) provider, PostgreSQL(9.5) DB and liberty server
This is what I get in the browser
And here are my entities in simple view
@Entity
public class GeoArea{
private Integer id;//Auto Generated
private String name;
private Set<TourismOrganization> organizations;
//getter and setter methods
@ManyToMany(mappedBy = "geoAreas")
public Set<TourismOrganization> getOrganizations() {
return organizations;
}
public void setOrganizations(Set<TourismOrganization> organizations) {
this.organizations = organizations;
}
}
@Entity
public class TourismOrganization{
private Integer id;//Auto Generated
private String name;
private BinaryContent logo;
private Set<TourismGeoArea> geoAreas;
//other getter and setter methods
@ManyToMany
public Set<TourismGeoArea> getGeoAreas() {
return geoAreas;
}
public void setGeoAreas(Set<TourismGeoArea> geoAreas) {
this.geoAreas = geoAreas;
}
@OneToOne(fetch = FetchType.EAGER, optional = true, cascade = { CascadeType.REMOVE }, orphanRemoval = true)
public BinaryContent getLogo() {
return logo;
}
public void setLogo(BinaryContent logo) {
this.logo = logo;
}
}
@Entity
public class BinaryContent{
private Integer id;//Auto Generated
private String contentType;
private byte[] data;
//other getter and setter methods
@Lob
@Column(length = 16000000) // This should generate a medium blob
@Basic(fetch = FetchType.LAZY) // I've read this is default, but anyway...
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
}
Any Idea how to solve this problem when getting organizations under geoArea by using >> geoArea.organizations in xhtml page?