Blog

ColdBox 4.0 ORM Services

Brad Wood February 12, 2015

Spread the word

Brad Wood

February 12, 2015

Spread the word


Share your thoughts

ColdBox's ORM services have always been a very compelling part of the framework for those using ORM in their applications.  The provide you with an automatic, extendable service layer for an ORM entity complete with common methods, pagination and really sweet syntactical sugar such as dynamic finders:

user = userService.findByLastName("Majano");
users = userService.findAllByLastLoginBetween( "01/01/2014", "01/01/2015" );
count = userService.countByLastLoginGreaterThan( "01/01/2013" );

All that sweetness is still there, but part of the cborm module so it's truly optional for those who want it.  Install cborm with CommandBox with this command while sitting in your web root:

CommandBox> install cborm

This module also replaces the old ORMService plugin as well.  It contains all the same services, but the component paths have been changed.  Here's a quick reference.  Do an extended find on your code base and replace any instances of the old component paths with the new. 

Old component path New component path
coldbox.system.orm.hibernate.VirtualEntityService cborm.models.VirtualEntityService
coldbox.system.orm.hibernate.ActiveEntity cborm.models.ActiveEntity
coldbox.system.orm.hibernate.BaseORMService cborm.models.BaseORMService

The cborm mapping will home in on the root of your ORM module regardless of where it's installed.  Unfortunately, due to the way that ORM is loaded by ColdFusion, if you are using the ORM EventHandler or ActiveEntity or any ColdBox Proxies that require ORM, you must create an Application Mapping in the Application.cfc like this:

this.mappings[ "/cborm" ] = COLDBOX_APP_ROOT_PATH & "modules/cborm";

Adjust the path as necessary to match your installation.

The same WireBox DSL namespaces are still available to you for injecting entity services.  The ORM Module will register these when it is activated.

// Inject a global ORM service
property name="genericEntityservice" inject="entityservice";

// Inject a Virtual entity service according to entityName
property name="foobarService" inject="entityservice:foobar";

 

Add Your Comment

Recent Entries

Mastering Events and Listeners in CBWIRE

Mastering Events and Listeners in CBWIRE

In CBWIRE, events and listeners are the backbone of building responsive, modular applications without relying heavily on JavaScript. This guide walks you through setting up and using CBWIRE events to create seamless interactions between components, from dispatching events in CFML and frontend templates to listening with Alpine.js and JavaScript. Learn how to make your applications feel dynamic and engaging by effortlessly connecting components. Whether you’re triggering events to update a dashboard or targeting specific parts of your app with dispatchTo, these techniques will empower you to create a modern, interactive CFML experience with ease.

Grant Copley
Grant Copley
November 11, 2024
10 Key Benefits of Hiring a Specialized ColdFusion Consulting Team

10 Key Benefits of Hiring a Specialized ColdFusion Consulting Team

ColdFusion remains a powerful and versatile platform for building dynamic web applications. However, keeping your ColdFusion environment optimized, secure, and scalable requires specialized expertise. Whether managing a long-standing ColdFusion application or planning new development projects, hiring a dedicated ColdFusion consulting and support team can be a game-changer for CTOs, CIOs, and developers. Here's why:

1. Expert Guidance on ColdFusion Web Development

...

Cristobal Escobar
Cristobal Escobar
November 08, 2024
ColdBox Free Tip 5 - Building Named Routes with a Struct

ColdBox Free Tip 5 - Building Named Routes with a Struct

**Did you know ColdBox provides flexible ways to build routes using structs?** In this tip, we’ll cover how to use the `event.buildLink()` and `event.route()` methods for named routes, a feature that’s especially handy when working with dynamic URLs.

Maria Jose Herrera
Maria Jose Herrera
November 07, 2024