deleteByID error since M6 update

Hi all,

Having issues with deleteByID() since updating to M6. I am sure this
worked before I updated.

The following line returns the error below...

thisCount = campaignService.deleteByID("campaign",4,true);
Error Type: Application : [N/A]
Error Messages: java.lang.ClassCastException: java.lang.String cannot
be cast to java.lang.Integer

is this a bug or has something I missed?


I believe curt discover this in the difference of string and numerical primary keys via hql.

Curt has some workarounds. I'll wait for him to post but it's a java casting issue

The issue is that CF is casting your ID as a string instead of an Int. If you strongly cast your ID it should fix the issue.

getPlugin("ORMService").deleteByID('SomeEntity',[javaCast("int", id)]);


We are working also on a way to simplify this issue. Curt has some greAt ideas but we still have not settled for anything.

Curt maybe you can share it with the group?

Thanks Curt, after Luis posted I Googled and found using javaCast
worked yes...

campaignService.deleteByID( [javaCast("int", 1)] );

I found a very interested post on stack over flow that shows the top
things to watch out for using CF9 ORM...

wonder what and how CB is dealing with some of these problems?

The issue comes in when we are using the native Hibernate query methods to create the query and execute it, like in deleteByID or getAll. Then we are in the java world and strict typing is enforced. My idea was to add a method like this one below to query the metadata and get the correct java type for the ID. This method would be used for both the deleteByID and the getAll methods of our baseORMService. I am not in love with the name, so if anyone has a better one, let me know. Also give me your feedback and if you guys like it, I can implement it into the service.

Curt Gratz
Computer Know How

      * Coverts an ID, list of ID's, or array of ID's values to the proper java type
      * The method returns a coverted array of ID's
      array function convertIDValueToJavaType(required string entityName, required any id){
            var hibernateMD = ormGetSessionFactory().getClassMetaData(arguments.entityName);

            //id conversion to array
            if( isSimpleValue( ){
         = listToArray(;

                  for (var i=1; i lte arrayLen(; i=i+1){
              [i] = hibernateMD.getIdentifierType().fromStringValue([i]);
            catch(Any e){


I understand the problem, I won't pretend I understand your solution,
but if Luis can incorporate this workaround into CB core, that would
be good.