-->
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.  [ 6 posts ] 
Author Message
 Post subject: join updates table?
PostPosted: Wed Jan 21, 2004 3:16 pm 
Beginner
Beginner

Joined: Fri Nov 28, 2003 11:21 am
Posts: 49
Location: Buenos Aires, Argentina
Doing the following join :

lasSecciones = GuiSGP.session.find("select seccion from Seccion seccion "+
"join seccion.vigencia vigencia "+
"where F_IdSuplemento =" + idSuplemento + " and A_Habilitado =" + 1 +
" and A_BajaLogica =" + 0 +" and vigencia.fechaDesde > '"+fecha+"'" );

Makes hibernate update vigencia ,why is that happening ?.

Hibernate: select secciones0_.P_IdElementoEditorial as P_IdElem1___, secciones0_.F_IdSuplemento as F_IdSupl2___, vigencia1_.P_IdVigencia as P_IdVige1_0_, vigencia1_.A_FechaDesde as A_FechaD2_0_, vigencia1_.A_FechaHasta as A_FechaH3_0_, vigencia1_.A_Descripcion as A_Descri4_0_, secciones0_.P_IdElementoEditorial as P_IdElem1_1_, secciones0_.F_IdSuplemento as F_IdSupl2_24_1_, secciones0__1_.A_Nombre as A_Nombre21_1_, secciones0__1_.A_Habilitado as A_Habili3_21_1_, secciones0__1_.A_BajaLogica as A_BajaLo4_21_1_, secciones0__1_.A_Orden as A_Orden21_1_, secciones0__1_.F_IdVigencia as F_IdVige6_21_1_ from T_Seccion secciones0_ inner join T_ElementoEditorial secciones0__1_ on secciones0_.P_IdElementoEditorial=secciones0__1_.P_IdElementoEditorial left outer join T_Vigencia vigencia1_ on secciones0__1_.F_IdVigencia=vigencia1_.P_IdVigencia where secciones0_.F_IdSuplemento=?
Hibernate: update T_Vigencia set A_FechaDesde=?, A_FechaHasta=?, A_Descripcion=? where P_IdVigencia=?
Hibernate: select seccion0_.P_IdElementoEditorial as P_IdElem1_, seccion0_.F_IdSuplemento as F_IdSupl2_24_, seccion0__1_.A_Nombre as A_Nombre21_, seccion0__1_.A_Habilitado as A_Habili3_21_, seccion0__1_.A_BajaLogica as A_BajaLo4_21_, seccion0__1_.A_Orden as A_Orden21_, seccion0__1_.F_IdVigencia as F_IdVige6_21_ from T_Seccion seccion0_ inner join T_ElementoEditorial seccion0__1_ on seccion0_.P_IdElementoEditorial=seccion0__1_.P_IdElementoEditorial inner join T_Vigencia vigencia1_ on seccion0__1_.F_IdVigencia=vigencia1_.P_IdVigencia where (vigencia1_.A_FechaDesde>'01-01-2005' )and(F_IdSuplemento=3 )and(A_Habilitado=0 )and(A_BajaLogica=0 )

maps:

<hibernate-mapping>
<class name="Common.Vigencia" table="T_Vigencia">
<id name="idVigencia" column="P_IdVigencia" type="int">
<generator class="identity"/>
</id>
<property name="fechaDesde" column="A_FechaDesde" type="date"/>
<property name="fechaHasta" column="A_FechaHasta" type="date"/>
<property name="descripcion" column="A_Descripcion" type="string"/>
</class>
</hibernate-mapping>


<hibernate-mapping>
<class name="Productos.ElementoEditorial" table="T_ElementoEditorial">
<id name="idElementoEditorial" column="P_IdElementoEditorial" type="int" unsaved-value="any" >
<generator class="identity"/>
</id>
<property name="nombre" column="A_Nombre" type="string"/>
<property name="habilitado" column="A_Habilitado" type="boolean"/>
<property name="bajaLogica" column="A_BajaLogica" type="boolean"/>
<property name="orden" column="A_Orden" type="int"/>
<many-to-one name="vigencia" class="Common.Vigencia" column="F_IdVigencia"/>
<bag name="eeFrecuencia" lazy="false" cascade="all-delete-orphan">
<key column="F_IdElementoEditorial" />
<one-to-many class="Productos.EEFrecuencia"/>
</bag>
<joined-subclass name="Productos.Producto" table="T_Producto">
<key column="P_IdElementoEditorial"/>
<many-to-one name="organizacion" class="Common.Organizacion" column="F_IdOrganizacion"/>
<bag name="suplementos" lazy="false" cascade="all-delete-orphan" inverse="true">
<key column="F_IdProducto" />
<one-to-many class="Productos.Suplemento"/>
</bag>
</joined-subclass>
<joined-subclass name="Productos.Suplemento" table="T_Suplemento">
<key column="P_IdElementoEditorial" />
<many-to-one name="producto" class="Productos.Producto" column="F_IdProducto"/>
<bag name="secciones" lazy="false" cascade="all-delete-orphan" inverse="true">
<key column="F_IdSuplemento" />
<one-to-many class="Productos.Seccion"/>
</bag>
</joined-subclass>
<joined-subclass name="Productos.Seccion" table="T_Seccion">
<key column="P_IdElementoEditorial"/>
<many-to-one name="suplemento" class="Productos.Suplemento" column="F_IdSuplemento"/>
</joined-subclass>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 5:08 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There is probably something wrong in your POJOs implementation or executed code. Hibernate don't update stuffs unless you do.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 1:55 am 
Beginner
Beginner

Joined: Fri Nov 28, 2003 11:21 am
Posts: 49
Location: Buenos Aires, Argentina
ok,it doesnt update phisically the records in the table vigencia,but it updates vigencia (cached?)to be the same value as the suplemento


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 8:29 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hibernate: update T_Vigencia set A_FechaDesde=?, A_FechaHasta=?, A_Descripcion=? where P_IdVigencia=?
means Hibernate physically updates the row.

Your request is OK, there is something wrong elsewhere

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 1:54 pm 
Beginner
Beginner

Joined: Fri Nov 28, 2003 11:21 am
Posts: 49
Location: Buenos Aires, Argentina
You are right,the setter of the class was doing something like this

this.vigencia_after =vigencia.before

Now,its working great thanks emmanuelle.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2004 5:25 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Jean Cartier wrote:
Now,its working great thanks emmanuelle.


*gggg*


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.