Could you please help me. I'v two clacess:
...
<hibernate-mapping>
<class
name="by.belsoft.tts.core.model.project.ProjectUser"
table="tts_project_user"
lazy="false"
>
<composite-id>
<key-property
name="portalUserId"
column="portal_user_ID"
length="255"
type="java.lang.String"
/>
<key-many-to-one
name="project"
class="by.belsoft.tts.core.model.project.Project"
column="project_ID"
/>
</composite-id>
</class>
</hibernate-mapping>
and:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class
name="by.belsoft.tts.core.model.project.Project"
table="tts_project"
lazy="false"
>
<id
name="projectId"
type="java.lang.Integer"
column="project_ID"
>
<generator class="increment" />
</id>
<!--
... properties
-->
<set
name="projectUsers"
lazy="false"
inverse="true"
cascade="all-delete-orphan"
>
<key
on-delete="cascade"
not-null="true"
column="project_ID"
/>
<one-to-many
class="by.belsoft.tts.core.model.project.ProjectUser"/>
</set>
<!--
...
-->
I know about the
http://www.hibernate.org/hib_docs/refer ... -onetomany.
And I'v the following proplem:
while I try to update the Project with set of ProjectUsers I have the following:
nested exception is org.springframework.dao.DataIntegrityViolationException: (Hibernate operation: Could not execute JDBC batch update): data integrity violated by SQL 'insert into tts_project_user (portal_user_ID, project_ID) values (?, ?)'; nested exception is java.sql.BatchUpdateException: Column 'portal_user_ID' cannot be null
The equals and hashCode were tested and the ProjectUser class is serializabled.