Problemas com Lazy no Hibernate

0 respostas
C

Pessoal, estou com seguinte problema em minha aplicação onde estou usando HIbernate:

Na Entity NcNoticiaCrime tenho o seguinte relacionamento:

@ManyToMany(cascade = CascadeType.PERSIST,fetch = FetchType.LAZY, mappedBy = ncNoticiaCrimes)	

public List getNcPessoas() {

return this.ncPessoas;

}
Na Entity NcPessoa tenho o seguinte relacionamento:

@ManyToMany(fetch = FetchType.EAGER)

@JoinTable(name = NC_PESSOA_NOTICIA_CRIME, schema = U_DSIT, joinColumns = { @JoinColumn(name = ID_PESSOA, nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = ID_NOTICIA_CRIME, nullable = false, updatable = false) })

public List getNcNoticiaCrimes() {

return this.ncNoticiaCrimes;

}

Quando tento executar o código abaixo ele lança a excessão:

if(!noticiaCrime.getNcPessoas().isEmpty()){

for(NcPessoa pessoa: noticiaCrime.getNcPessoas()){

PessoaNoticiaCrime pnc = new PessoaNoticiaCrime(pessoa.getIdPessoa(),noticiaCrime.getIdNoticiaCrime());

session.delete(pnc);

}

}

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: br.gov.es.sefaz.noticiacrime.entidade.NcNoticiaCrime.ncPessoas, no session or session was closed
Criado 18 de fevereiro de 2009
Respostas 0
Participantes 1