1
votes

I am having another problem with my ORM app in ColdFusion. When I try to insert a new child object I am getting the error below. Updates work fine.

The root cause of this exception was: coldfusion.orm.hibernate.HibernateSessionException: [Macromedia][Oracle JDBC Driver][Oracle]ORA-01400: cannot insert NULL into ("AKC"."T_BREED_PAGE_TEXT_CONTENT_WEB"."KEY_TEXT_CONTENT") .

This is the orm cfc:

<cfcomponent persistent="true"
      table="T_BREED_PAGE_TEXT_CONTENT_WEB" 
      schema="akc"  >

    <cfproperty name="KEY_TEXT_CONTENT" fieldtype="id"   generator="sequence" params="{sequence='akc.seq_breed_page_display'}" />
    <cfproperty name="TEXT_TITLE_TEXT" />
    <cfproperty name="TEXT_ICON_IMAGE" />
    <cfproperty name="TEXT_CONTENT" />
    <cfproperty name="KEY_BREED_PAGE" />
    <cfproperty name="CDE_BLOCK_ID"  />
    <cfproperty name="breedPage" cfc="breedPage" fieldtype="many-to-one" fkcolumn="KEY_BREED_PAGE" />
    <cfproperty name="pageBlocks" cfc="pageBlocks" fieldtype="many-to-one" fkcolumn="CDE_BLOCK_ID" />
</cfcomponent>

I have tried it with the coldfusion increment generator as well as setting the value manually with the same error generated. A normal cfquery insert using the sequence works fine. Any thoughts on a fix for this?

Thanks

2

2 Answers

0
votes

Did you try generator="identity" and have the db auto-increment the PK?

0
votes

Oddly, I ran into a very similar problem after posting my previous answer. After getting into the nitty-gritty of hibernate logging and analyzing what my save method was actually doing, I discovered that in saving a user object with an array of address objects, after removing an address, hibernate was trying to remove the address by setting the FK userID field in the address record to NULL, but my schema didn't allow nulls. Putting inverse="true" on the Addresses property resolved it. Perhaps your issue is somewhat similar.

When you say you're inserting a new child, where exactly is the exception being thrown? I'm curious to know what ORM functions you're calling.

Not sure what to call that object, but for argument sake let's call it a SubBreed() Are you doing SubBreed.setBreedPage(new BreedPage); then entitySave(SubBreed)? Or something else entirely?