What am I doing wrong, or how can I fix this? I need to be able to automatically and manually set the ID number.
The line
prc.incoming.save( forceInsert=true );
works but inserts a new doc_id instead of using the one that I provided. If I dump the contents of the prc.incoming before the save the values are correct. If I insert into the database directly with sql manually it works correctly so it is not my triggers.
Thank you for any suggestions of guidance.
Aaron
Environment: Linux based CF9
Model
component entityName=“doc” persistent=“true” extends=“coldbox.system.orm.hibernate.ActiveEntity” table=“tbname” schema=“myschema” {
property name=“DOC_ID” column=“doc_id” fieldtype=“id” generator=“sequence” sequence=“myschema.seq_name” ormtype=“integer”;
…
}
Handler
var doc = getModel(“doc”);
if( event.valueExists( “doc_id”) and rc.DOC_ID neq “” ) {
logger.debug( “Updating doc ###rc.doc_id#” );
prc.incoming = doc.get( rc.doc_id, true );
if( isNull( prc.incoming ) ) {
logger.debug( “Saving new incoming document” );
var new_id = { doc_id=rc.doc_id };
prc.incoming = doc.new(entityName=“doc”, properties=new_id );
prc.incoming = populateModel( prc.incoming );
prc.incoming.setDATE_INPUTTED( now() );
prc.incoming.setPROCESSOR( rc.user_info.uid );
prc.incoming.save( forceInsert=true );
}
}