Loaded object was of wrong class

1,887 views
Skip to first unread message

Tony Nelson

unread,
Jun 8, 2010, 12:10:58 PM6/8/10
to cf-orm-dev
Has anyone come across this error before?

Object with id: {id} was not of the specified subclass: {Entity}
(loaded object was of wrong class class
coldfusion.orm.PersistentTemplateProxy)

Nando

unread,
Jun 8, 2010, 3:03:51 PM6/8/10
to cf-or...@googlegroups.com
Showing more detail might help. What code block triggered this error?


--
You received this message because you are subscribed to the Google Groups "cf-orm-dev" group.
To post to this group, send email to cf-or...@googlegroups.com.
To unsubscribe from this group, send email to cf-orm-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cf-orm-dev?hl=en.




--
Nando M. Breiter
The CarbonZero Project
CP 234
6934 Bioggio
Switzerland

+41 91 606 6372

na...@carbonzero.ch
www.carbonzero.ch

Tony Nelson

unread,
Jun 8, 2010, 6:02:44 PM6/8/10
to cf-orm-dev
I was just loading in objects, similar to the following simplified
version:

var query= ormGetSession().createQuery("from Category");
return query.list();

-Tony

On Jun 8, 2:03 pm, Nando <d.na...@gmail.com> wrote:
> Showing more detail might help. What code block triggered this error?
>
>
>
> On Tue, Jun 8, 2010 at 6:10 PM, Tony Nelson <tonynelso...@gmail.com> wrote:
> > Has anyone come across this error before?
>
> > Object with id: {id} was not of the specified subclass: {Entity}
> > (loaded object was of wrong class class
> > coldfusion.orm.PersistentTemplateProxy)
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "cf-orm-dev" group.
> > To post to this group, send email to cf-or...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > cf-orm-dev+...@googlegroups.com<cf-orm-dev%2Bunsu...@googlegroups.com>
> > .

Brian Kotek

unread,
Jun 8, 2010, 6:12:48 PM6/8/10
to cf-or...@googlegroups.com
You'll have to show the CFCs and how you're defining any inheritance hierarchies. It sounds like you've got a misconfiguration in one of the CFCs.

To unsubscribe from this group, send email to cf-orm-dev+...@googlegroups.com.

Tony Nelson

unread,
Jun 8, 2010, 9:06:00 PM6/8/10
to cf-orm-dev
Yeah I thought it would be a configuration error, but the CFC in
question is pretty simple (ID, name, array of products) and only
extends a base entity. Plus the error doesn't happen all the time, but
just started recently without any changes after it had been working
for quite awhile. I'll try to see if I can find out any more info.

-Tony

On Jun 8, 5:12 pm, Brian Kotek <brian...@gmail.com> wrote:
> You'll have to show the CFCs and how you're defining any inheritance
> hierarchies. It sounds like you've got a misconfiguration in one of the
> CFCs.
>
> On Tue, Jun 8, 2010 at 6:02 PM, Tony Nelson <tonynelso...@gmail.com> wrote:
> > I was just loading in objects, similar to the following simplified
> > version:
>
> > var query= ormGetSession().createQuery("from Category");
> > return query.list();
>
> > -Tony
>
> > On Jun 8, 2:03 pm, Nando <d.na...@gmail.com> wrote:
> > > Showing more detail might help. What code block triggered this error?
>
> > > On Tue, Jun 8, 2010 at 6:10 PM, Tony Nelson <tonynelso...@gmail.com>
> > wrote:
> > > > Has anyone come across this error before?
>
> > > > Object with id: {id} was not of the specified subclass: {Entity}
> > > > (loaded object was of wrong class class
> > > > coldfusion.orm.PersistentTemplateProxy)
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "cf-orm-dev" group.
> > > > To post to this group, send email to cf-or...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > cf-orm-dev+...@googlegroups.com<cf-orm-dev%2Bunsu...@googlegroups.com>
> > <cf-orm-dev%2Bunsu...@googlegroups.com<cf-orm-dev%252Buns...@googlegroups.com>

Brian Kotek

unread,
Jun 8, 2010, 11:30:08 PM6/8/10
to cf-or...@googlegroups.com
Hearing confirmation that the CFC extends another entity leads me to believe that it is almost certainly a configuration issue. If you post the code for the CFCs someone may be able to offer some advice.

To unsubscribe from this group, send email to cf-orm-dev+...@googlegroups.com.

Tony Nelson

unread,
Jun 9, 2010, 9:41:12 AM6/9/10
to cf-orm-dev
Let me clarify that a bit. It doesn't extend an ORM entity, but a base
component.

-Tony

On Jun 8, 10:30 pm, Brian Kotek <brian...@gmail.com> wrote:
> Hearing confirmation that the CFC extends another entity leads me to believe
> that it is almost certainly a configuration issue. If you post the code for
> the CFCs someone may be able to offer some advice.
>
> > > > <cf-orm-dev%2Bunsu...@googlegroups.com<cf-orm-dev%252Buns...@googlegroups.com>
> > <cf-orm-dev%252Buns...@googlegroups.com<cf-orm-dev%25252Bun...@googlegroups.com>

Tony Nelson

unread,
Jul 8, 2010, 10:36:22 PM7/8/10
to cf-orm-dev
This started happening again (out of the blue), so here's a little
more info. It's actually happening in one of my ColdMVC sample
applications now, so you can see all the code if you want:

Here's the full Hibernate config:
http://github.com/tonynelson19/ColdMVC/blob/master/samples/blog/config/hibernate.hbmxml

Here's the CFC in question: http://github.com/tonynelson19/ColdMVC/blob/master/samples/blog/app/model/Category.cfc

Here's part of the stack trace from the error:

org.hibernate.WrongClassException: Object with id: 1 was not of the
specified subclass: Category (loaded object was of wrong class class
coldfusion.orm.PersistentTemplateProxy)
at org.hibernate.loader.Loader.instanceAlreadyLoaded(Loader.java:
1267)
at org.hibernate.loader.Loader.getRow(Loader.java:1219)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:603)
at org.hibernate.loader.Loader.doQuery(Loader.java:724)
at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:
259)
at org.hibernate.loader.Loader.loadCollection(Loader.java:2015)
at
org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:
59)
at
org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:
587)
at
org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:
83)
at
org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:
1743)
at
org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:
366)
at
org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:
108)
at
org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:
131)
at org.hibernate.collection.PersistentBag.size(PersistentBag.java:
248)
at coldfusion.runtime.Array.ArrayLen(Array.java:295)
at coldfusion.runtime.CFPage.ArrayLen(CFPage.java:553)
at cfdata2ecfc568547502$funcCOUNT.runFunction(C:\workspace\coldmvc\app
\helpers\data.cfc:28)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472)
at coldfusion.runtime.UDFMethod
$ReturnTypeFilter.invoke(UDFMethod.java:405)
at coldfusion.runtime.UDFMethod
$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
at
coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:
55)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:490)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:336)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2360)
at cfModel2ecfc1121264920$funcHAS.runFunction(C:\workspace\coldmvc
\Model.cfc:138)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472)
at coldfusion.runtime.UDFMethod
$ReturnTypeFilter.invoke(UDFMethod.java:405)
at coldfusion.runtime.UDFMethod
$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
at
coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:
55)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:490)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:336)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2360)
at cf_post2ecfm1888749378.runPage(C:\workspace\coldmvc\samples\blog
\.generated\views\post\_post.cfm:9)
etc...

Also, the error seems to happen with both lazy="true" and lazy="false"
on my relationships in case that matters.

If anyone is feeling ambitious, they could try downloading ColdMVC and
running the sample applications for themselves to see if it happens to
them too.

All help is appreciated.

-Tony

Bob Silverberg

unread,
Jul 9, 2010, 12:03:09 AM7/9/10
to cf-or...@googlegroups.com
Hey Tony,

I downloaded ColdMVC and tried running the sample app, to see if I get
the same result, but I got an error message regarding a mapping for
"app", which I would have assumed would be created automatically. If
you want to take the debugging of that offlist I'd be happy to try to
get the sample running and see if I can recreate the problem. Either
send me an email or ping me on IM.

Cheers,
Bob

--
Bob Silverberg
www.silverwareconsulting.com

Hands-on ColdFusion ORM Training
www.ColdFusionOrmTraining.com

Tony Nelson

unread,
Jul 9, 2010, 9:46:48 AM7/9/10
to cf-orm-dev
Bob,

Thanks for your help. I'll try to ping you sometime later in the day.

- Tony

On Jul 8, 11:03 pm, Bob Silverberg <bob.silverb...@gmail.com> wrote:
> Hey Tony,
>
> I downloaded ColdMVC and tried running the sample app, to see if I get
> the same result, but I got an error message regarding a mapping for
> "app", which I would have assumed would be created automatically. If
> you want to take the debugging of that offlist I'd be happy to try to
> get the sample running and see if I can recreate the problem.  Either
> send me an email or ping me on IM.
>
> Cheers,
> Bob
>
>
>
> On Thu, Jul 8, 2010 at 10:36 PM, Tony Nelson <tonynelso...@gmail.com> wrote:
> > This started happening again (out of the blue), so here's a little
> > more info. It's actually happening in one of my ColdMVC sample
> > applications now, so you can see all the code if you want:
>
> > Here's the full Hibernate config:
> >http://github.com/tonynelson19/ColdMVC/blob/master/samples/blog/confi...
>
> > Here's the CFC in question:http://github.com/tonynelson19/ColdMVC/blob/master/samples/blog/app/m...

Tony Nelson

unread,
Jul 13, 2010, 1:35:09 PM7/13/10
to cf-orm-dev
Just a quick update. I deleted all the records in my Post_Category
table and that seemed to fix the issue, although that's a little
strange solution since the FK constraints should've prevented bad data
from being inserted into the database. I'm content for now I guess.
Thanks for your help Bob.

-Tony

Robert Rawlins

unread,
Feb 28, 2011, 1:13:02 PM2/28/11
to cf-or...@googlegroups.com
Hi Tony,

I'm seeing this exact same issue myself today. Out of the blue.

I'm seeing this in a ColdBox application. Strangely enough, when accessing the event itself the page loads just fine. However, when running an integration test on the event I get this exception thrown.

Really odd. After some googling it seems like there are a few people with the problem, but nobody with a solution.

Thanks,

Robert

Tony Nelson

unread,
Feb 28, 2011, 2:00:28 PM2/28/11
to cf-orm-dev
Well at least I'm not totally crazy. :)

-Tony

Robert Rawlins

unread,
Feb 28, 2011, 2:29:25 PM2/28/11
to cf-or...@googlegroups.com
Haha well no.

But considering I've managed to achieve pretty much nothing recently without running into ORM bugs I may be in a padded cell before you know it.

Robert

> --
> You received this message because you are subscribed to the Google Groups "cf-orm-dev" group.
> To post to this group, send email to cf-or...@googlegroups.com.

> To unsubscribe from this group, send email to cf-orm-dev+...@googlegroups.com.

Greg Moser

unread,
Jun 17, 2011, 12:52:23 PM6/17/11
to cf-or...@googlegroups.com
Hey guys... I just ran into this same problem, out of the blue one of my views is tossing this error and it wasn't around yesturday... Nothing has changed.

Did anyone ever figure out what might be causing it?  How did you guys solve it?

-Greg

Greg Moser

unread,
Jun 17, 2011, 1:02:17 PM6/17/11
to cf-or...@googlegroups.com
Wow... Just did an application reload and it went away... This scares me.  Seems like a Coldfusion or Hibernate Bug.

I guess I'll just keep my fingers crossed and hope this issue doesn't randomly pop-up again.  Hopefully this is a bug that people smarter than me know about and are working on... looks like it was reported here: http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html#bugId=85227

-Greg

Stefan de Koning

unread,
Jun 20, 2011, 6:05:59 AM6/20/11
to cf-or...@googlegroups.com
When I encounter this error myself, it has always been due to Hibernate's case sensitivity for entity names. If you strictly use the exact same case notation for entities across the entire application (especially check for file names and relationship definitions), it will probably fix your problem.




2011/6/17 Greg Moser <gr...@gregmoser.com>
Wow... Just did an application reload and it went away... This scares me.  Seems like a Coldfusion or Hibernate Bug.

I guess I'll just keep my fingers crossed and hope this issue doesn't randomly pop-up again.  Hopefully this is a bug that people smarter than me know about and are working on... looks like it was reported here: http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html#bugId=85227

-Greg

--
You received this message because you are subscribed to the Google Groups "cf-orm-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cf-orm-dev/-/ezkAWTcp4CwJ.

James

unread,
Jul 17, 2011, 5:56:08 PM7/17/11
to cf-orm-dev
I ran into the issue even while using the proper case. There seems to
be a cache of entity names.

For good measure I made all entities and their references all
lowercase, but I still had to clear the CF Admin template and
component cache in order for the changes to take effect. I figured
this out when the error named the formerly initial uppercase entity
names after I had changed them.

That being said, changing entity names seems to increase the chance of
seeing the issue. Also avoid using entity names that are the same as
Hibernate terms such as "model". I had some entities named "model" and
"property". I changed them to "datamodels" and "dataproperties".

Hope that helps.

On Jun 20, 5:05 am, Stefan de Koning <stefan.dekon...@gmail.com>
wrote:
> When I encounter this error myself, it has always been due to Hibernate's
> case sensitivity for entity names. If you strictly use the exact same case
> notation for entities across the entire application (especially check for
> file names and relationship definitions), it will probably fix your problem.
>
> 2011/6/17 Greg Moser <g...@gregmoser.com>
>
>
>
>
>
>
>
> > Wow... Just did an application reload and it went away... This scares me.
> >  Seems like a Coldfusion or Hibernate Bug.
>
> > I guess I'll just keep my fingers crossed and hope this issue doesn't
> > randomly pop-up again.  Hopefully this is a bug that people smarter than me
> > know about and are working on... looks like it was reported here:
> >http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html#...

Owen Allen

unread,
Dec 4, 2012, 6:34:34 PM12/4/12
to cf-or...@googlegroups.com
I have experienced this issue quite a bit and it's extremely frustrating. I am basically 99% certain that it's a Coldfusion bug which I'm still trying to find a viable work around for. The problem only shows up sometimes, code can work for days and then suddenly it goes wrong. It's certainly due to some internal caching somewhere. Most of the suggestions regarding casing or naming do not seem to resolve anything. Doing an OrmReload() will always solve the problem, temporarily. Likewise, renaming cfcs and reloading appears to solve it, but it solves it only because the OrmReload() solves it.

When you are stuck in the problem it has to do with reloading an object that has already been loaded. In addition, at least for me, it has to do with OrmExecuteQuery(). In addition, it only occurs when doing discriminators  such that a relationship array can be loaded but each entity will have (possibly) a different class. 

// no error
EntityLoadByPk("something", 8);
EntityLoadByPk("something", 8);

// error (wtf!?)
OrmExecuteQuery("SELECT m FROM something WHERE id = 8");
OrmExceuteQuery("SELECT m FROM something WHERE id = 8");

Martha Tischuk

unread,
Jan 10, 2013, 3:01:31 PM1/10/13
to cf-or...@googlegroups.com
I recently came across this error in my ColdFusion API and I found a solution that works for me. The error is as follows:


Object with id: {id} was not of the specified subclass: {Entity}
(loaded object was of wrong class class
coldfusion.orm.
PersistentTemplateProxy)

I was seeing this issue when I inserted data into a particular ORM component (did an EntitySave operation), and then performed an EntityLoad operation on the component more than once in a certain function. This was occurring for two of the components in my architecture (they are called accounts and cards).

For example:
in Transactions.cfc

function AddValue()
{    
      EntitySave(card);
      EntityLoad(cards);
    ----------------------------
      EntityLoad(cards); // Receive error here.
}

I will note that I also have two data views in my database that were created from the accounts and cards tables, and these views are represented by ORM in my architecture as well. And I will also note that my databases and ORM are generated dynamically using a script I created. Basically, I have a blank test database and ORM for the blank test database that the script reads and uses to generate the 'real' database and ORM.

To solve my issue, I changed the two blank test database ORM components (accounts and cards) to have the property:

savemapping="true"

I reloaded the ORM and generated the database from my script. I then performed the AddValue operation and no error had occurred.

Todd Sharp

unread,
Feb 8, 2013, 10:57:34 AM2/8/13
to cf-or...@googlegroups.com
If you receive this exception when using ORM Inheritance with an object that has multiple properties that extend a base class I've found that a workaround is to add a where clause to the property itself - where="discriminatorColumn=disriminatorValue".  
Reply all
Reply to author
Forward
0 new messages