[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1909?page=c...
]
Mario Balaban commented on HHH-1909:
------------------------------------
Have similar problem. I used hibernate tools to generate the entities, dao, and hbm files.
Now when I'm trying to save the entity Iscritti that have this part as the
Iscritti.hbm.xml : ...
<class name="com.model.Iscritti" table="ISCRITTI">
<many-to-one name="agenzie" class="com.model.Agenzie"
update="false" insert="false" fetch="select">
<column name="ABI" length="5" not-null="true"
/>
<column name="CAB" length="5" not-null="true"
/>
</many-to-one>
.... and this is Agenzie.hbm.xml ...
<class name="com.model.Agenzie" table="AGENZIE">
<composite-id name="id" class="com.model.AgenzieId">
<key-property name="abi" type="string">
<column name="ABI" length="5" />
</key-property>
<key-property name="cab" type="string">
<column name="CAB" length="5" />
</key-property>
</composite-id>
....
I get an Exception saying that the column CAB cannot be null, even if the property
"agenzie" of Iscritti have been set with an entity retrieved from the DB. An
indeed in the sql produced by Hibernate does not set this column when persisting the
entity Iscritti.
Incomplete insert and update using <<insert="false"
update="false">>
--------------------------------------------------------------------
Key: HHH-1909
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1909
Project: Hibernate Core
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira