[coldbox 5.1] - Using ORM, how to get id of last inserted record after calling save()?

Hi,

I’m new to using ORM with ColdBox. I have an object where I am calling the save method and it’s saves it to my database, but I can’t find a method to get the ID of the newly inserted record. My database generates the id as the primary key. I am using CF 11 and mysql as well if that helps to know.

I have this code in my handler:

var objUser = ORMService.populate( ORMService.new( “User” ), rc );
ORMService.save(entity=objUser);

The save() works, but not sure how to get the id.

Any help appreciated.

Thanks!

Is it present in objUser if you call the getter on the primary key property after saving?

Turns out you are right, I dumped the object out and there is a getter associated with the primary key.

Thanks for the quick assistance. I normally dump an object and check all the properties/methods, but somehow just missed it this time so thanks!