I have a 2 objects Configuration and ConfigurationId with a 1:m relation.
If i load a ConfigurationId in one transaction, and uses it to create a new Configuration in another transaction, i get a "Cannot insert the value NULL into column 'configurationId', table 'ecc.dbo.Configuration'; column does not allow nulls. INSERT fails"
It looks like Castor inserts null instead of the id of the ConfigurationId object.
db.begin();
ConfigurationId id = (ConfigurationId)db.load(id.getClass(),new Integer(1));
db.commit();
db.begin();
cfg = new Configuration();
cfg.setConfigurationId(id);
cfg.addConfigItem(i);
db.create(cfg);
db.commit();
If i evaluate the Configuration object before it is created, it looks fine.
If i run it in one transaction, it works.
Any ideas?
- Michael
<!-- Mapping for Configuration -->
<class name="dk.tdc.ctiudv.ecc.configuration.Configuration"
identity="id" key-generator="MAX" access="shared" >
<description>Configuration</description>
<map-to table="Configuration" />
<field name="id" type="integer">
<sql name="id" type="integer" />
<xml name="id" node="attribute"/>
</field>
<field name="ConfigurationId" type="dk.tdc.ctiudv.ecc.configuration.ConfigurationId">
<sql name="configurationid" />
<xml node="element" name="Configuration id"/>
</field>
<field name="TimeStamp" type="long">
<sql name="time_stamp" type="integer"/>
<xml node="text" />
</field>
</class>
<!-- Mapping for ConfigurationId -->
<class name="dk.tdc.ctiudv.ecc.configuration.ConfigurationId" identity="id" key-generator="MAX" access="shared" >
<description>ConfigurationId</description>
<map-to table="ConfigurationId" xml="items" />
<field name="id" type="integer">
<sql name="id" type="integer"/>
<xml node="attribute"/>
</field>
<field name="ApplicationName" type="string">
<sql name="name" type="char"/>
<xml node="text" />
</field>
<field name="ApplicationVersion" type="string">
<sql name="version" type="char"/>
<xml node="text" />
</field>
<field name="User" type="string">
<sql name="user" type="char"/>
<xml node="text" />
</field>
<field name="Machine" type="string">
<sql name="machine" type="char"/>
<xml node="text" />
</field>
<field name="Location" type="string">
<sql name="location" type="char"/>
<xml node="text" />
</field>
<field name="Other" type="string">
<sql name="other" type="char"/>
<xml node="text" />
</field>
<field name="TimeStamp" type="long">
<sql name="time_stamp" type="integer"/>
<xml node="text"/>
</field>
</class>
