Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hi,
I have a composite-element that can be read normally but I can´t get the field "LIDO" updated. I really don´t know what is going on...
Any ideas? Thanks.
Hibernate version:
3.2 cr2
Mapping documents:
<hibernate-mapping>
<class name="Aviso" table="AVISO">
<id name="id" type="long">
<column name="ID_AVISO" not-null="true" />
<generator class="identity" />
</id>
<set name="destinatarios"
table="AVISO_USUARIO"
cascade="save-update">
<key column="ID_AVISO" not-null="true" />
<many-to-many column="ID_USUARIO" class="Usuario" />
</set>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="Usuario" table="USUARIO">
<id name="id" type="long">
<column name="ID_USUARIO" not-null="true" />
<generator class="identity" />
</id>
<set name="avisos"
table="AVISO_USUARIO"
inverse="true"
cascade="save-update">
<key column="ID_USUARIO" not-null="true" />
<composite-element class="AvisoUsuario">
<property name="lido" type="boolean">
<column name="LIDO" default="0" not-null="true" />
</property>
<many-to-one name="aviso"
column="ID_AVISO"
class="Aviso" />
</composite-element>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Usuario usuario = session.get(Usuario.class, 1);
usuario.getAvisos().iterator().next().setLido(true);
session.merge(usuario);
Name and version of the database you are using:
MySQL 5.0
The generated SQL (show_sql=true):
Hibernate: select avisos0_.ID_USUARIO as ID2_0_, avisos0_.LIDO as LIDO0_, avisos
0_.ID_AVISO as ID1_0_ from AVISO_USUARIO avisos0_ where avisos0_.ID_USUARIO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?
Hibernate: select aviso0_.ID_AVISO as ID1_1042_0_, aviso0_.TITULO as TITULO1042_
0_, aviso0_.ORIGEM as ORIGEM1042_0_, aviso0_.CRIACAO as CRIACAO1042_0_, aviso0_.
INICIO as INICIO1042_0_, aviso0_.FIM as FIM1042_0_, aviso0_.CORPO as CORPO1042_0
_, aviso0_.TIPO_DESTINATARIO as TIPO8_1042_0_, aviso0_.ID_DESTINATARIO as ID9_10
42_0_, aviso0_.ID_USUARIO as ID10_1042_0_ from AVISO aviso0_ where aviso0_.ID_AV
ISO=?