Hi all,
Hib version 2.1.4., Oracle 8i.
The basic problem is this. I have an Article object with a List (mapped as an Idbag) of Topics. With this project I inherited a non-hib friendly DB design so i'm using the ID bag to fill in a (useless) ID PK on what is basically a many-to-many lookup table. When I create a new Article and add topics to the List, everything saves correctly. However, when I update the Article and add a new topic to the list, Hib tries to insert null in the Idbag's ID field, which being a PK can't be null. Can't quite figure out why. Here are the gory details (TIA):
Mapping for the Article class:
Code:
<hibernate-mapping>
<class name="Article" table="CECN_ARTICLE">
<id name="id" column="ID" type="integer" unsaved-value="0">
<generator class="native">
<param name="sequence">news_sequence</param>
</generator>
</id>
<property name="status">
<column name="STATUS" sql-type="varchar2(50)" not-null="true"/>
</property>
<property name="title">
<column name="TITLE" sql-type="varchar2(1000)" not-null="true"/>
</property>
<property name="longSummary">
<column name="TOPSTORYSUMMARY" sql-type="varchar2(4000)" not-null="false"/>
</property>
<property name="shortSummary">
<column name="SUMMARY" sql-type="varchar2(4000)" not-null="false"/>
</property>
<property name="feedbackName">
<column name="FDBK_NAME" sql-type="varchar2(300)" not-null="true"/>
</property>
<property name="feedbackEmailAddr">
<column name="FDBK_EMAIL_ADDR" sql-type="varchar2(50)" not-null="true"/>
</property>
<property name="assignerEmplid">
<column name="ASSIGNER" sql-type="varchar2(11)" not-null="false"/>
</property>
<property name="assigneeEmplid">
<column name="ASSIGNEE" sql-type="varchar2(11)" not-null="false"/>
</property>
<property name="submissionEmplid">
<column name="SUBM_EMPLID" sql-type="varchar2(11)" not-null="true"/>
</property>
<property name="submissionComments">
<column name="SUBM_COMMENTS" sql-type="varchar2(4000)" not-null="false"/>
</property>
<property name="dateDisplay" type="java.util.Date">
<column name="DTE_DISPLAY" sql-type="timestamp" not-null="true"/>
</property>
<property name="dateAssigned" type="java.util.Date">
<column name="DTE_ASSIGNED" sql-type="timestamp" not-null="false"/>
</property>
<property name="dateExpiration" type="java.util.Date">
<column name="DTE_EXPIRE" sql-type="timestamp" not-null="false"/>
</property>
<property name="dateSubmitted" type="java.util.Date">
<column name="DTE_SUBMITTED" sql-type="timestamp" not-null="true"/>
</property>
<property name="dateUpdated" type="java.util.Date">
<column name="DTE_UPDATED" sql-type="timestamp" not-null="false"/>
</property>
<property name="dateCompleted" type="java.util.Date">
<column name="DTE_COMPLETED" sql-type="timestamp" not-null="false"/>
</property>
<property name="dateApproved" type="java.util.Date">
<column name="DTE_Approved" sql-type="timestamp" not-null="false"/>
</property>
<property name="dateDue" type="java.util.Date">
<column name="DTE_DUE" sql-type="timestamp" not-null="false"/>
</property>
<property name="link">
<column name="LINK" sql-type="number(1)" not-null="true"/>
</property>
<property name="outsideUrl">
<column name="OUTSIDE_URL" sql-type="varchar2(1000)" not-null="false"/>
</property>
<property name="execAnnouncement" type="boolean">
<column name="ISEXECANN" sql-type="number(1)" not-null="true"/>
</property>
<property name="execOrg">
<column name="EXECORG" sql-type="varchar2(300)" not-null="false"/>
</property>
<property name="execEmplid">
<column name="EXEC_SUBM_EMPLID" sql-type="varchar2(11)" not-null="false"/>
</property>
<property name="externalSource">
<column name="EXTERNAL_SRC" sql-type="varchar2(100)" not-null="false"/>
</property>
<!-- NOTE: this collection doesn't really need to have a key
(worked fine as a set) but since the ref table does i'm using IDBAG -->
<idbag name="topics" table="CECN_ARTICLE_REF" lazy="true">
<collection-id column="ID" type="integer">
<generator class="native">
<param name="sequence">news_sequence</param>
</generator>
</collection-id>
<key column="CECN_ARTICLE_ID"/>
<many-to-many column="CECN_CH_TPC_ID" class="Topic"/>
</idbag>
<set name="images" lazy="true" inverse="true" cascade="all-delete-orphan">
<key column="CECN_ARTICLE_ID"/>
<one-to-many class="Media"/>
</set>
<set name="mediaTypes" table="CECN_ARTICLE_MEDIA_TYPES" lazy="true">
<key column="CECN_ARTICLE_ID"/>
<many-to-many column="CECN_IMG_ID" class="MediaType"/>
</set>
<map name="headlines" table="CECN_HEADLINE" lazy="true">
<key column="CECN_ARTICLE_ID"/>
<index-many-to-many column="CECN_HDL_SET_ID" class="Headline"/>
<element type="integer" column="PLACEMENT"/>
</map>
<set name="metadata" table="CECN_ARTICLE_MDF" lazy="true">
<key column="CECN_ARTICLE_ID"/>
<many-to-many column="CECN_MDF_ID" class="Metadata"/>
</set>
<map name="comps" table="CECN_ARTICLE_COMPONENT" lazy="true">
<key column="CECN_ARTICLE_ID"/>
<index-many-to-many column="CECN_CHANNEL_ID" class="Channel"/>
<many-to-many column="CECN_COMPONENT_ID" class="Comp"/>
</map>
<set name="additionalExecs" lazy="true" inverse="true" cascade="all-delete-orphan">
<key column="CECN_ARTICLE_ID"/>
<one-to-many class="Exec"/>
</set>
<set name="permissions" table="CECN_ARTICLE_PERMISSION" lazy="true">
<key column="CECN_ARTICLE_ID"/>
<many-to-many column="CECN_PERM_ID" class="Permission"/>
</set>
</class>
</hibernate-mapping>
Mapping for the Topic class:
Code:
<hibernate-mapping>
<class name="Topic" table="CECN_CHANNEL_TOPIC">
<id name="id" column="ID" type="integer" unsaved-value="0">
<generator class="native">
<param name="sequence">news_sequence</param>
</generator>
</id>
<many-to-one
name="category"
column="CECN_CATEGORY_ID"
class="Category"/>
<property name="name">
<column name="NAME" sql-type="varchar2(400)" not-null="true" />
</property>
</class>
</hibernate-mapping>
Thanks in advance for any help.