Hi there,
I'm facing a quite weird behavior of hibernate. This is what happens: right after the deployment of my application I try to log in with some of the registered users. When this is done, I can see in the logs that there is a INSERT statement being executed when there is no persist or merge calls in the code, just readings.
This is the method of my managed bean:
Code:
public List<SelectItem> getListaUFs() {
if( listaUFs == null ) {
listaUFs = unidadeFederacaoDAO.getTodasUnidadesFederacao();
}
List<SelectItem> ufs = new ArrayList<SelectItem>();
for( UnidadeFederacao uf : listaUFs ) {
ufs.add( new SelectItem( uf.getId(), uf.getSigla() ) );
}
return ufs;
}
This is the implementation of my DAO:
Code:
@SuppressWarnings( "unchecked" )
public List<UnidadeFederacao> getTodasUnidadesFederacao() {
Query query = em.createNamedQuery( UnidadeFederacao.QUERY_PESQUISA_TODAS_UNIDADES_FEDERACAO );
return query.getResultList();
}
This is the description of my query:
Code:
@Entity
@Table(name = "UFS")
@NamedQueries({
@NamedQuery( name=UnidadeFederacao.QUERY_PESQUISA_TODAS_UNIDADES_FEDERACAO,
query="SELECT u FROM UnidadeFederacao u ORDER BY u.sigla" )
})
public class UnidadeFederacao implements Serializable {
private static final long serialVersionUID = 7199743356113430585L;
public static final String QUERY_PESQUISA_TODAS_UNIDADES_FEDERACAO = "queryPesquisaTodasUnidadesFederacao";
}
And this is the exeption I'm getting:
Code:
00:26:16,273 INFO [STDOUT] Hibernate:
select
unidadefed0_.id as id10_,
unidadefed0_.sigla as sigla10_
from
ampb_1.UFS unidadefed0_
order by
unidadefed0_.sigla
00:26:16,323 INFO [STDOUT] Hibernate:
insert
into
ampb_1.ENDERECOS
(logradouro, bairro, numero, complemento, cep, cidade, idUF, id)
values
(?, ?, ?, ?, ?, ?, ?, ?)
00:26:19,890 ERROR [STDERR] Jul 13, 2010 12:26:19 AM com.sun.facelets.FaceletViewHandler handleRenderException
SEVERE: Error Rendering View[/pages/publico/index.xhtml]
javax.faces.FacesException: javax.el.ELException: /pages/publico/detalharEnderecos.xhtml @30,62 value="#{consultasController.listaUFs}": Error reading 'listaUFs' on type br.org.ampb.controller.ConsultasController
As can be seen, hibernate is issuing an INSERT statement where there is no need of inserts. My EJBQL is just issuing an insert.
How is it possible that? Am I making something wrong? How can I fix this?
Thanks for any advice.
Loreno