[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1909) Incomplete insert and update using <<insert="false" update="false">>

Karol Nowak (JIRA) noreply at atlassian.com
Tue Apr 8 09:38:33 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29969 ] 

Karol Nowak commented on HHH-1909:
----------------------------------

I had the same problem. This is indeed irritating. Another solution is to set the properties accordingly in the setter for the associations, based on the other object. This, however, will break if the second object is initialized after the connection is set.

> Incomplete insert and update using <<insert="false" update="false">>
> --------------------------------------------------------------------
>
>                 Key: HHH-1909
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1909
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.0 final
>            Reporter: Peppe
>            Priority: Critical
>
> Hi, I've seen lots of people have problems using complex mappings.
> This is my situation, I've three mappings:
> <hibernate-mapping>
>     <class name="unibiblio.dati.anagrafica.DAO.Persone" table="persone">
>         <composite-id name="id" class="unibiblio.dati.anagrafica.DAO.PersoneId">
>             <key-property name="idUtente" type="java.lang.Integer">
>                 <column name="id_utente" />
>             </key-property>
>             <key-property name="codbib" type="java.lang.Integer">
>                 <column name="codbib" />
>             </key-property>
>         </composite-id>
>         <many-to-one name="dizTitolidistudio" class="unibiblio.dati.anagrafica.DAO.DizTitolidistudio" update="false" insert="false" fetch="select">
>             <column name="lingua" length="2" />
>             <column name="codice_titolostudio" length="1" />
>         </many-to-one>
>         <many-to-one name="dizLingue" class="unibiblio.dati.anagrafica.DAO.DizLingue" fetch="select">
>             <column name="lingua" length="2" />
>         </many-to-one>
>         <many-to-one name="dizProfessioni" class="unibiblio.dati.anagrafica.DAO.DizProfessioni" update="false" insert="false" fetch="select">
>             <column name="lingua" length="2" />
>             <column name="codprofessione" length="2" not-null="true" />
>         </many-to-one>
>         <property name="userName" type="string">
>             <column name="user_name" length="30" />
>         </property>
>         <property name="password" type="string">
>             <column name="password" length="30" />
>         </property>
>         .
>         .
>         .
>         .
>         .
>         .
>     </class>
> </hibernate-mapping>
> <hibernate-mapping>
>     <class name="unibiblio.dati.anagrafica.DAO.DizTitolidistudio" table="diz_titolidistudio">
>         <composite-id name="id" class="unibiblio.dati.anagrafica.DAO.DizTitolidistudioId">
>             <key-property name="lingua" type="string">
>                 <column name="lingua" length="2" />
>             </key-property>
>             <key-property name="codiceTitolostudio" type="string">
>                 <column name="codice_titolostudio" length="1" />
>             </key-property>
>         </composite-id>
>         <many-to-one name="dizLingue" class="unibiblio.dati.anagrafica.DAO.DizLingue" update="false" insert="false" fetch="select">
>             <column name="lingua" length="2" not-null="true" />
>         </many-to-one>
>         <property name="titolo" type="string">
>             <column name="titolo" length="50" not-null="true" />
>         </property>
>         <set name="persones" inverse="true">
>             <key>
>                 <column name="lingua" length="2" />
>                 <column name="codice_titolostudio" length="1" />
>             </key>
>             <one-to-many class="unibiblio.dati.anagrafica.DAO.Persone" />
>         </set>
>     </class>
> </hibernate-mapping>
> <hibernate-mapping>
>     <class name="unibiblio.dati.anagrafica.DAO.DizProfessioni" table="diz_professioni">
>         <composite-id name="id" class="unibiblio.dati.anagrafica.DAO.DizProfessioniId">
>             <key-property name="lingua" type="string">
>                 <column name="lingua" length="2" />
>             </key-property>
>             <key-property name="codprofessione" type="string">
>                 <column name="codprofessione" length="2" />
>             </key-property>
>         </composite-id>
>         <many-to-one name="dizLingue" class="unibiblio.dati.anagrafica.DAO.DizLingue" update="false" insert="false" fetch="select">
>             <column name="lingua" length="2" not-null="true" />
>         </many-to-one>
>         <property name="professione" type="string">
>             <column name="professione" length="50" />
>         </property>
>         <set name="persones" inverse="true">
>             <key>
>                 <column name="lingua" length="2" />
>                 <column name="codprofessione" length="2" not-null="true" />
>             </key>
>             <one-to-many class="unibiblio.dati.anagrafica.DAO.Persone" />
>         </set>
>     </class>
> </hibernate-mapping>
> The problem is when I try to insert a new persone it make an incomplete SQL statement because 
> <<update="false" insert="false">> in <many-to-one name="dizTitolidistudio"> and <many-to-one name="dizProfessioni">
> causes hiding setting of columns "codice_titolostudio" and "codprofessione" in the generated SQL
> Deleting that tag, of course, give me the exception
> 	ERROR [STDERR] org.hibernate.MappingException: Repeated column in mapping for entity: unibiblio.dati.anagrafica.DAO.Persone column: lingua (should be mapped with insert="false" update="false")
> 	
> I workarounded this extracting "codice_titolostudio" and "codprofessione" as properties in Persone and setting them with 
> classes but I don't like this. Am I wrong or is it a bug?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list