Dutch Rapley

RSS

Needed ColdFusion Hibernate Improvements

Adobe made some nice improvements to Hibernate integration in the latest 9.0.1 update.

The nicest addition is the ability to work with multiple datasources in a single application.

I feel the implementation leaves much to be desired. Here’s where it falls short:

  1. Additional datasources are differentiated with the “datasource” attribute in the CFC metadata
  2. Across all datasources in an app, entity names have to be unique
  3. There’s no flexibility with entityLoad() - see #2 above

I feel that a couple of minor improvements could be made:

  1. Have a Application.cfc setting for this.ormsettings.datasources, this could provide some additional, useful functionality. You would no longer need to specify the datasource in the CFC’s attributes.

    this.ormsettings.datasources = [
    {datasource=”ds1”,
    cfclocation=[“com/myorg/orm”]},

    {datasource=”ds2”,
    cfclocation=[“com/myorg/moreorm”, ”com/bmic/evenmoreorm”]}
    ];

2) working with entityLoad() and entityNew()

Currently, if you’re working with entityNew(), you have a nice work around, and that’s because you can instantiate ORM objects with createObject(). Granted, you’re still at the mercy of dealing with unique entities.

I realize it wouldn’t be right to add an additional attribute to entityLoad() and entityNew() for the datasource, but the following could be options for implementation when dealing with multiple hibernate sessions:

entityNew(“path.to.SomeEntity”)
entityNew(“ds1:SomeEntity”)

entityLoad(“path.to.SomeEntity”, 100, true)
entityLoad(“ds1:SomeEntity”, 100 true)

entityLoadByPK() would require the same enhancement as entityLoad()

entitySave() wouldn’t need to be updated since the entity is aware of the datasource it belongs to.