野蝇 16,注释@JsonIgnore不起作用



我使用wildfly 1-,并实现了一个web服务rest

@Entity
@XmlRootElement
public class Promotion implements Serializable {
@Id
private String acronyme;
private String intitule;
@OneToMany(fetch = FetchType.EAGER)
private List<Etudiant> etudiants = new ArrayList<>();
@OneToMany
private List<Module> modules; 
public Promotion() {}
public Promotion(String titre,String acronyme) {
this.intitule = titre;
this.acronyme = acronyme;
etudiants = new ArrayList<Etudiant>();
}
.......... etc
}
@Path(value="/promotions")
public class RestServicePromotion {
@Inject
private MetierItf metier;
@GET
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
public List<Promotion> lireTousPromotion() {
System.out.println(metier.lireTousPromotion());
return metier.lireTousPromotion();
}
.... etc
}

当我想调用mémethod lireTousPromotion((时,我有一个例外:


/7EtudiantPromotionPPresentationOut/rest/production:
org.jboss.retasy.spi.未处理异常:
org.hibernate.LazyInitializationException的异常处理请求:未能延迟初始化角色集合:entite。Promotion.module,无法初始化代理-没有会话

我不知道我怎么能不分析模块字段。未设置@JsonIgnore

尝试对Promotion#modules字段使用javax.xml.bind.annotation.XmlTransient注释。

更多信息:http://blog.bdoughan.com/2012/04/jaxb-and-unmapped-properties.html

相关内容

最新更新