Thursday, May 31, 2012

Wednesday, May 30, 2012

ORM gotchas - Child Mapping Issues

This is another work use-case example. We had a need to use some of the parent/child inheritance that ORM provides using a discriminator column (adobe's docs on using a subclass with discriminator).

The reasoning, is that there were specific types of children that had specific data attributes (it all revolved around a rule engine where the results had a shared set of data points, but depending on the rule type, the actual result data would change dramatically) and so, to avoid having a bunch of null values in the parent table, we were going to create the child tables appropriately.

Here's where it started to get tricky. We needed to map a relationship from the child object to a different table because, well because that relationship existed. Unfortunately, ORM didn't like that...

Sunday, May 27, 2012

Random result set with HQL

Being a night owl I was browsing stack overflow when I came across a post about how to generate a random ordered result set with entityLoad() in ColdFusion. I (as of writing this) still haven't come up with a logical reason why one would _want_ to do so, but to each their own.

So, after a bit of research and testing the short answer is: It's really difficult to do with entityLoad().

However, with HQL, it's super easy:

Being aware of ORM sessions and gotchas

So recently at work I was trying to troubleshoot an odd issue I had never seen before. I was getting an odd error from a relatively simple HQL query:

Root cause :org.hibernate.HibernateException: coldfusion.runtime.Cast$NumberConversionException: The value '' cannot be converted to a number.

Informative, right?

The query being ran was a simple fetch query along the lines of:
hql = "FROM artists WHERE id = :id";
artist = ormExecuteQuery( hql, {id = 1}, true); 

Basically, there was nothing to indicate that there was a numeric value that was being populated with a null string.

So where did the error come from?

Friday, May 25, 2012

MXUnit Boiler Plate 2.0 is here!

A while back, I decided that stubbing out all the unit tests for an existing component was very, very tedious. So, I wrote a terse cfBuilder extension that had a few simple options to generate stubs of your tests.

After having my coding fire reignited at cfObjective last week, I decided that it was time to update the extension to be a bit more useful. ( GET IT HERE )

So, for those of you lovely individuals who are using mxUnit ( Get mxUnit here ) you now have an option to save you some more of the tedious overhead for generating your unit tests.

Thursday, May 24, 2012

First post! Here's hoping it breaks the internet...

I'm too cheap to fork out for a monthly server like some well-to-do ColdFusion developers we know *cough* Dan *cough* Ray, so I'll be embarrassingly putting things up here for a while. If in the future it seems like I should migrate to my own server well, we'll *insert metaphor here* when it happens.

Follow by Email