I have an entity setup like this:
@Entity
@Table(name = "APP", uniqueConstraints = @UniqueConstraint(columnNames = "APP_KEY"))
public class Application implements java.io.Serializable {
...
@OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "application_Id", referencedColumnName = "application_Id")
private Set<Document> documents = new HashSet<Document>(0);
}
Now, in some situations I don't want the list of documents to be returned. However when I serialize this object the "getDocuments()" method will be called.
There will not be an active transaction at this time, so I don't want one of those "no session" errors. I just want to ignore it and have the getDocuments() method return empty, not throw an exception and not try to fetch more data.