RE: [coldbox:18404] [coldbox-3.5.3] Weird ORM Issue [loaded object was of wrong class]

It depends-- what cache provider are you using?



ColdBox Platform Evangelist
Ortus Solutions, Corp

ColdBox Platform:

I’m using ehCache, vanilla config.

In my development environment, I’ve tried evicting the entity, as well as all queries. No change. If I ORMReload(), the problem is resolved. However, the moment I restart CF, the error comes back (for the exact same entities).

I am clearly missing something, but I have no idea what. Is there a way to simply bomb the entire cache and start over?


I ser you have two personid is that normal

Those are just the PK and FK in my tables

They have the same name?

Yes, they do.

Alright, here are my findings (thin and disappointing as they are).

  • Whenever I do a CF restart, the issue appears

  • When I subsequently ormReload(), the issue is resolved

  • When I subsequently restart CF, the issue reappears
    I thought this was a caching issue at first, but now I’m not so sure. In my flailing to find an answer, I went back to my original query:

c = StuffService.newCriteria(); c.createAlias( 'Person', 'p' ).isEq( 'p.PersonID', someid ).list()

Instead of creating an alias, I simply used a SQL restriction:

c = StuffService.newCriteria(); c.sqlRestriction( "PersonID= '#arguments.criteria[ crit ]#'" ).list();

After switching to this, everything seems to work as expected, without the drama of ormReload() vs. CF restart.

I’m still not sure why the former criteria query caused that error, but I suspect that perhaps it has something to do with the relationships that exist between Person and other entities through the app. Maybe something down the line in the relationship chain got some wires crossed…who knows.

Anyway, that’s my workaround for now. I’d like to understand fully what was happening, but deadlines are calling my name :slight_smile:


Luis F. Majano
Ortus Solutions, Corp

ColdBox Platform:
Linked In:
IECFUG Manager: