In attempt to change my code to follow recommendations in the reference document I am getting the following error:
Code:
Try to insert null into a non-nullable column: column: CAMPAIGN_ID table: EDITION in statement [insert into EDITION (TITLE, EMAIL_SUBJECT, MAIN_TEXT, TRACKABLE_LINK, LAYOUT, EDITION_ID) values (?, ?, ?, ?, ?, null)]>
2004-07-28 09:59:11,113 ERROR [net.sf.hibernate.util.JDBCExceptionReporter] - <could not insert: [com.fp.eMarketing.dataModels.Edition]>
I know I'm missing one keyword somewhere in my HBM file, I'm just not sure where.
My edition HBM is as follows:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.fp.eMarketing.dataModels.Edition" table="EDITION">
<id name="editionID" type="int" column="EDITION_ID" unsaved-value="0">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>
<property name="title" type="string">
<column name="TITLE" not-null="true" unique="true" index="TITLE_IDX"/>
</property>
<property name="emailSubject" type="string">
<column name="EMAIL_SUBJECT" not-null="true"/>
</property>
<property name="mainText" type="text">
<column name="MAIN_TEXT" not-null="true"/>
</property>
<property name="includeTrackableLink" type="boolean">
<column name="TRACKABLE_LINK" not-null="true"/>
</property>
<property name="layout" type="int">
<column name="LAYOUT" not-null="true"/>
</property>
<one-to-one name="campaigns" class="com.fp.eMarketing.dataModels.Campaign"
foreign-key="CAMPAIGN_FK"/>
</class>
</hibernate-mapping>
and my campaign hbm is as follows:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.fp.eMarketing.dataModels.Campaign" table="CAMPAIGN">
<id name="campaignID" type="int" column="CAMPAIGN_ID" unsaved-value="0">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>
<property name="title" type="string">
<column name="TITLE" not-null="true" unique="true" index="TITLE_IDX"/>
</property>
<property name="type" type="int">
<column name="TYPE" not-null="true" unique="false"/>
</property>
<property name="contactName" type="string">
<column name="CONTACT_NAME" not-null="true"/>
</property>
<property name="contactEmail" type="string">
<column name="CONTACT_EMAIL" not-null="true"/>
</property>
<property name="administrationEmail" type="string">
<column name="ADMIN_EMAIL" not-null="true"/>
</property>
<property name="postAddress1" type="string">
<column name="POST_ADDRESS1" not-null="true"/>
</property>
<property name="postAddress2" type="string">
<column name="POST_ADDRESS2" not-null="true"/>
</property>
<set name="editions" table="CAMPAIGN_EDITIONS" inverse="true" cascade="all-delete-orphan">
<key column="CAMPAIGN_ID"/>
<one-to-many class="com.fp.eMarketing.dataModels.Edition"/>
</set>
</class>
<query name="com.fp.eMarketing.retrieveAllCampaigns">
<![CDATA[
from com.fp.eMarketing.dataModels.Campaign as c
]]>
</query>
</hibernate-mapping>
Campaign is the parent and Edition is the child.
Before I just had the one-to-many in Campaign and this was fine for saving data, but it did not do a retrieval. After filtering through the documents it seemed I had to set up the additional relationship and this is when the save stopped working.
Any help would be great.