-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Select causing insert?
PostPosted: Mon Jul 12, 2010 11:47 pm 
Newbie

Joined: Mon Jul 12, 2010 11:37 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.