Search code examples
hibernateormcoldfusioncoldfusion-9coldfusion-11

ColdFusion ORM and default constructors (init method)


Hibernate requires a no-args constructor and in all languages that does support method overloading that's probably not an issue, but I've faced a really annoying issue in ColdFusion ORM (which relies on Hibernate under the hood).

If I declare a custom constructor (an init method) for my entities and that constructor requires some arguments, Hibernate fails to rehydrate my entities because it's calling the custom constructor.

Because of that behavior, it seems almost impossible to design always-valid entities and therefore makes CF-ORM close to being completely useless.

The only work-around I found is to declare another custom method that I use as a constructor which makes instanciating objects now look like new SomeEntity().construct(...) or createObject('component', 'SomeEntity').construct(...). That's quite cumbersome...

What's very stupid in all this is that you can instanciate an entity without calling the init method using createObject, so I wonder why they decided to make Hibernate call the init method in their implementation, considering the fact that it's not even passing parameters and sets them afterwards by other means.

Anyway, is there any other work around for that issue?

EDIT:

I filed a bug in the Adobe Bugbase.


Solution

  • After many efforts in making this request approved, it has been fixed.

    Nimit Sharma

    5:08:05 AM GMT+00:00 Nov 20, 2015

    This issue is fixed and the fix will be available as part of next major release of ColdFusion.

    We have introduced a property "orminitmethod" at component level to address this issue. Subcomponent do not inherit orminitmethod. It behaves exactly like initmethod.

    I have logged another tracking bug #4090267 to have an application level setting