-->
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.  [ 3 posts ] 
Author Message
 Post subject: createQuery launches an update ?
PostPosted: Thu Aug 04, 2005 11:48 am 
Beginner
Beginner

Joined: Thu Jun 30, 2005 5:15 am
Posts: 21
Hi,

I'm using Hibernate 3.0.5. Sometimes when I launch the following code:

Code:
        System.out.println("Start");
        List l = HibernateUtil.getSession()
          .createQuery("from Entidad where idAnualidad = ?")
          .setInteger(0, idAnualidad)
          .list();
        System.out.println("End");


I get the following log:

Code:
Start

Hibernate: update ca_entidad set nombre=?, observaciones=?, idProvincia=?, idTipoentidad=?, idAnualidad=? where identidad=?

Hibernate: select entidad0_.identidad as identidad, entidad0_.nombre as nombre3_, entidad0_.observaciones as observac3_3_, entidad0_.idProvincia as idProvin4_3_, entidad0_.idTipoentidad as idTipoen5_3_, entidad0_.idAnualidad as idAnuali6_3_ from ca_entidad entidad0_ where entidad0_.idAnualidad=?

End

An update before the select. Moreover: I didn't modify the entity class. The only "strange" thing is that it has spanish characters ("ñ" and "Ñ") in some properties.
Any comment here would be really welcome. As far as I know a createQuery() will never try to do an update, won't it ?

Regards,

- Juan

PS.: Just the plain simple mapping file being used:

Code:
<hibernate-mapping>
  <class table="opcion_menu" name="comun.menu.modelo.Nodo">
    <composite-id name="id" class="comun.menu.modelo.Nodo$ID">
      <key-property name="codigoAplicacion" column="cod_aplicacion"/>
      <key-property name="codigoMenu" column="cod_menu"/>
      <key-property name="ordenOpcion" column="orden_opcion"/>
    </composite-id> 
    <property name="codigoMenuSiguiente" column="cod_menu_siguiente" not-null="true"/>
    <property name="etiqueta" column="lit_opcion" not-null="true"/>
    <property name="programa" column="programa" not-null="true"/>
  </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: $ID huh?
PostPosted: Thu Aug 04, 2005 2:25 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
It looks like problem is that you have used nested class as ID so your class probably looks like this:

public class Nodo{

public class ID{
}
}

Try making it static like this:

public class Nodo{

public static class ID{
}
}

and then in the mapping use it:
<composite-id name="id" class="comun.menu.modelo.Nodo.ID"> [/b]


Top
 Profile  
 
 Post subject: Wrong mapping file
PostPosted: Fri Aug 05, 2005 3:06 am 
Beginner
Beginner

Joined: Thu Jun 30, 2005 5:15 am
Posts: 21
Sorry kgignatyev, I posted the wrong mapping file. The 'Entidad' mapping file is even more simple:

Code:
<hibernate-mapping>
  <class table="ca_entidad" name="conac.modelo.Entidad">
    <id name="idEntidad" column="identidad">
      <generator class="increment"/>
    </id>
    <property name="nombre" column="nombre" not-null="true"/>
    <property name="observaciones" column="observaciones" not-null="false"/>
    <property name="idProvincia" column="idProvincia" not-null="true"/>
    <property name="idTipoEntidad" column="idTipoentidad" not-null="true"/>
    <property name="idAnualidad" column="idAnualidad" not-null="true"/>
  </class>
</hibernate-mapping>


Sorry for the confusion (but thank you for your help!)


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

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.