Now let's build the same thing but using ColdFusion ORM and our ActiveEntity
approach from the ColdBox ORM Extensions module.
An object that represents a contact and self-validates using ColdBox Validation Module, and is an awesome ActiveEntity object. Let's use CommandBox to build it:
Then spice it up with the validation constraints
You will first make sure your contacts
datsource exists in the Administrator and then we can declare our ORM settings in our Application.cfc
These are the vanilla settings for using the ORM with ColdBox. Make sure that flushAtRequestEnd
and autoManageSession
are set to false as the ORM extensions will manage that for you.
In this example, we also use dbcreate="update"
as we want ColdFusion ORM to build the database for us which allows us to concentrate on the domain problem at hand and not persistence. You also see that we add our own eventHandler which points to the extension's event handler so we can make Active Entity become well, Active!
Now open your ColdBox.cfc
and add the following to activate ORM injections inside of your configure()
method.
That's right, go to the handler now, no need of data layers or services, we build them for you! This time, we show you the entire CRUD operations as Active Entity makes life easy!
Then spice it up