[coldbox 3.5.3] How do I force the ID of new orm entity

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.


Environment: Linux based CF9


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”;



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 );


Remove sequence as the generator, unless you are automatically creating your own sequence it would be best to use the default auto id for property id. If you are generating your own sequence then you can do this in the init, but be careful because you can then run into issues with concatenation and other management issues that you would need to do.