ORM Entity not available? Check your logs

This post is more than 2 years old.

This afternoon I was working on a set of persistent entities called event, eventtype, eventstatus, and eventpriority. Event is the "core" entity with hooks to status, type, and priority. When everything was done I whipped up a quick test:

<cfset o = entityLoadByPk("event", 597878)>

I assumed this would work - or throw an error about one of the properties perhaps. What I did not expect was this:

Mapping for component event not found.

That made no sense. I took a quick look at the Hibernate APIs to see if there was a simple way to list all known entities. I discovered getAllClassMetadata, a method of the SessionFactory, and quickly tried the following code:

<cfset factory = ormGetSessionFactory()> <cfset known = listSort(structKeyList(factory.getAllClassMetadata()),"textnocase")> <cfoutput>#known#</cfoutput>

This returned a nice list of entities - which unfortunately did not include event. At this point I was completely stumped. I had - of course, ran an ormReload() on my application. I even ran an applicationStop(). None of them threw an error, but none of them made event become recognized. Then I decided to check my ColdFusion logs. I found this gem in application.log:

"Skipping file c:\yada\yada\yada\event.cfc as it has errors"

What the frack?!?! So the component had an error - and the ORM system noticed this and just didn't tell me? How incredibly frustrating and counterintuitive! I checked exception.log and luckily, it had a longer error. My stack trace said:

"Properties cannot be declared more than once."

I quickly went back to event.cfc and saw the error right away - two properties with the same name. -sigh- Fixing that immediately corrected my problem.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate for HERE Technologies. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com