0
懒惰的关系,我有:实例化VStateBE这样的事情之前,系列化
@OneToMany(mappedBy = "vState", fetch = FetchType.LAZY)
private Set<VOptionBE> vOptions;
@Override
public Set<String> getSaList() {
if (saList == null) {
saList = new TreeSet<String>();
for (final VOptionBE option : vOptions) {
saList.add(normalizeSACode(option.getSa()));
}
}
return saList;
,并在其他类VOptionBE我:
@Id
@Column(name = "SA", length = 4)
private String sa;
@ManyToOne
@JoinColumn(name = "V_SHORT")
private VStateBE vState;
我收到以下错误:
Caused by: Exception [EclipseLink-7242] (Eclipse Persistence Services - 2.3.4.v20130626-0ab9c4c): org.eclipse.persistence.exceptions.ValidationException
Exception Description: An attempt was made to traverse a relationship using indirection that had a null Session. This often occurs when an entity with an uninstantiated LAZY relationship is serialized and that lazy relationship is traversed after serialization. To avoid this issue, instantiate the LAZY relationship prior to serialization.
它尝试从getSaList()方法读取时发生。