Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.05 and 3.1b3
Mapping documents:
<hibernate-mapping
>
<class
name="org.appfuse.model.ModelB"
table="tst_b"
>
<id
name="id"
column="id"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-ModelB.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<version
name="version"
column="version"
type="java.lang.Integer"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-ModelB.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Here's modela.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="org.appfuse.model.ModelA"
table="tst_b"
>
<id
name="id"
column="id"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-ModelA.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<version
name="version"
column="version"
type="java.lang.Integer"
/>
<many-to-one
name="modelBList"
class="org.appfuse.model.ModelB"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="id"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-ModelA.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
[junit] Error creating bean with name 'sessionFactory' defined in file [C:\tools\eclipse\eclipse
-data\workspace\test\build\dao\gen\META-INF\applicationContext-hibernate.xml]: Initialization of bea
n failed; nested exception is org.hibernate.MappingException: Repeated column in mapping for entity:
org.appfuse.model.ModelA column: id (should be mapped with insert="false" update="false")
[junit] org.springframework.beans.factory.BeanCreationException: Error creating bean with name '
sessionFactory' defined in file [C:\tools\eclipse\eclipse-data\workspace\test\build\dao\gen\META-INF
\applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is org.hibernate
.MappingException: Repeated column in mapping for entity: org.appfuse.model.ModelA column: id (shoul
d be mapped with insert="false" update="false")
[junit] org.hibernate.MappingException: Repeated column in mapping for entity: org.appfuse.model
.ModelA column: id (should be mapped with insert="false" update="false")
Name and version of the database you are using:
The generated SQL (show_sql=true):
MySQL 4.1
Debug level Hibernate log excerpt:
na