Installation

Quickly install cborm

Leverage CommandBox to install into your ColdBox app:

# Latest version
install cborm

# Bleeding Edge
install cborm@be

System Requirements

  • BoxLang 1.0+

  • Adobe ColdFusion 2023+

  • Lucee 5.x+

  • Hibernate 5.x+ (Hibernate 3 is no longer supported as of CBORM 4.9.0)

Application Setup

If you are using the ORM EventHandler or ActiveEntity or any ColdBox Proxies that require ORM, you must create an Application Mapping to the module in the Application.bx|cfc like this:

Application.bx|cfc
# In the pseudo constructor
this.mappings[ "/cborm" ] = COLDBOX_APP_ROOT_PATH & "modules/cborm";

This is required because the ORM engine is bootstraped before ColdBox fully initializes and thus the module paths are not yet registered.

WireBox DSL

The module registers a new WireBox DSL called entityservice which can produce virtual or base ORM entity services. Below are the injections you can use:

  • entityservice - Inject a global ORM service

  • entityservice:{entityName} - Inject a Virtual entity service according to entityName

Module Settings

Here are the module settings you can place in your ColdBox.cfc under moduleSettings -> cborm structure or by creating a cborm.cfc in the config/modules directory.

config/ColdBox.cfc
moduleSettings = {
    cborm = {
        // Resource Settings
    		resources : {
    			// Enable the ORM Resource Event Loader
    			eventLoader 	: false,
    			// Pagination max rows
    			maxRows 		: 25,
    			// Pagination max row limit: 0 = no limit
    			maxRowsLimit 	: 500
    		},
        // WireBox Injection bridge
        injection = {
            // enable entity injection via WireBox
            enabled = true,
            // Which entities to include in DI ONLY, if empty include all entities
            include = "",
            // Which entities to exclude from DI, if empty, none are excluded
            exclude = ""
        }
    }
}

ColdBox 7+ Config:

config/modules/cborm.bx
class{
  function configure(){
     return {
        // Resource Settings
        resources : {
            // Enable the ORM Resource Event Loader
            eventLoader : false,
            // Pagination max rows
            maxRows : 25,
            // Pagination max row limit: 0 = no limit
            maxRowsLimit : 500
        },
            // WireBox Injection bridge
            injection : {
                // enable entity injection via WireBox
                enabled : true,
                // Which entities to include in DI ONLY, if empty include all entities
                include : "",
                // Which entities to exclude from DI, if empty, none are excluded
                exclude : ""
            }
      }
    }
}

Validation

We have also integrated a UniqueValidator from the validation module into our ORM module. It is mapped into WireBox as UniqueValidator@cborm so you can use it in your model constraints like so:

{ fieldName : { validator: "UniqueValidator@cborm" } }

Supported Hibernate Versions

BoxLang 1.0+

Hibernate is bundled with the bx-orm module. Just install it via CommandBox:

install bx-orm

The version of Hibernate bundled is:

BoxLang Autocasting: As of CBORM 4.8.0, CBORM leverages BoxLang's intelligent autocasting capabilities. When running on BoxLang, CBORM passes values through directly to take advantage of BoxLang's smarter type handling, improving performance and type safety.

Lucee 5+

Hibernate is bundled with the Ortus ORM Extension for Lucee: https://forgebox.io/view/D062D72F-F8A2-46F0-8CBC91325B2F067B. You can find our source code here: https://github.com/ortus-solutions/extension-hibernate

You can install it via the Lucee Administrator, by using th extension ID: D062D72F-F8A2-46F0-8CBC91325B2F067B or via CommandBox:

box install D062D72F-F8A2-46F0-8CBC91325B2F067B

BY JVM argument

-Dlucee-extensions=D062D72F-F8A2-46F0-8CBC91325B2F067B

The version of Hibernate bundled is:

-Dhibernate.version=5.6.0.Final

Please note that our Lucee Hibernate Extension is on LTS and will only receive critical bug fixes and security patches. New features and enhancements will be focused on the BoxLang BX-ORM module.

Adobe 2023+

Last updated

Was this helpful?