This module will enhance your experience when working with the ColdFusion (CFML) ORM powered by Hibernate. It will not only enhance it with dynamic goodness but give you a fluent and human approach to working with Hibernate. It will finally make working with ORM NOT SUCK!
# A quick preview of some functionality
var book = new Book().findByTitle( "My Awesome Book" );
var book = new Book().getOrFail( 2 );
property name="userService" inject="entityService:User";
return userService.list();
return userService.list( asStream=true );
userService
.newCriteria()
.eq( "name", "luis" )
.isTrue( "isActive" )
.getOrFail();
userService
.newCriteria()
.isTrue( "isActive" )
.joinTo( "role" )
.eq( "name", "admin" )
.asStream()
.list();
userService
.newCriteria()
.withProjections( property="id,fname:firstName,lname:lastName,age" )
.isTrue( "isActive" )
.joinTo( "role" )
.eq( "name", "admin" )
.asStruct()
.list();
Apache License, Version 2.0.
Source & Changelog
Documentation
Issues
Support
Use CommandBox cli to install:
box install cborm
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";
This is due to the fact that the ORM event listener starts before ColdBox, so no dynamic mappings exist yet. Important: Make sure you ALWAYS lazy load dependencies in your event handlers to avoid chicken and the egg issues.
The module also registers a new WireBox DSL called entityservice
which can produce virtual or base ORM entity services:
entityservice
- Inject a global ORM service so you can work with ANY entityentityservice:{entityName}
- Inject a Virtual entity service according to entityName
Here are the module settings you can place in your config/Coldbox.cfc
under the moduleSettings.cborm
structure:
moduleSettings = {
cborm = {
// Resource Settings
resources : {
// Enable the ORM Resource Event Loader
eventLoader : false,
// Prefix to use on all the registered pre/post{Entity}{Action} events
eventPrefix : "",
// Pagination max rows
maxRows : 25,
// Pagination max row limit: 0 = no limit
maxRowsLimit : 500
},
// WireBox Injection Bridge
injection : {
enabled : true,
include : "",
exclude : ""
}
}
};
We have also migrated the UniqueValidator
from the validation module into our
ORM module. It is mapped into wirebox as UniqueValidator@cborm
so you can use in your constraints like so:
this.constraints = {
"name" : {
"required":true,
"validator":"UniqueValidator@cborm"
}
};
All contributions welcome! Feel free to fix a typo, add a feature :rocket:, or add a testbox spec for a newly discovered issue :bug:
If you want to get hacking on CBORM, here's how to start:
docker-compose.yml
file. Just make sure you have Docker installed. run-script startdbs
or run it manually below.docker run \
-e MYSQL_RANDOM_ROOT_PASSWORD=yes \
-e MYSQL_USER=other \
-e MYSQL_PASSWORD=ortussolutions \
-e MYSQL_DATABASE=coolblog \
-v "$PWD/test-harness/tests/resources":/docker-entrypoint-initdb.d \
-p 3306:3306 \
--detach \
--name cborm_mysql \
mysql
.env.template
to .env
and enter the database credentials used in step 2 above ☝box run-script install:dependencies
box start server-lucee@5.json
(You can use adobe or other engines)Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com
Because of His grace, this project exists. If you don't like this, then don't read it, its not for you.
"Therefore being justified by faith, we have peace with God through our Lord Jesus Christ: By whom also we have access by faith into this grace wherein we stand, and rejoice in hope of the glory of God. And not only so, but we glory in tribulations also: knowing that tribulation worketh patience; And patience, experience; and experience, hope: And hope maketh not ashamed; because the love of God is shed abroad in our hearts by the Holy Ghost which is given unto us. ." Romans 5:5
"I am the way, and the truth, and the life; no one comes to the Father, but by me (JESUS)" Jn 14:1-12