I have the following Entities(connected to db):
@Entity
public class Campaign {
// ...
@OneToMany(fetch = FetchType.LAZY)
private List<Subscriber> subscribers;
}
@Entity
public class Subscriber {
// ...
}
I want to fetch the Campaigns but ignore Subscribers. In my controller I jsonify Campaigns but that triggers an error because it attempts to lazy load Subscribers. In this case I don't want it to lazy load Subscribers, just print out the Campaigns (In other cases I want to print out both).
I tried selecting specific fields in an hql query but that returns an array not an object.