Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Open your config/ColdBox.cfc and either uncomment or add the following settings:
Please remember that you can use ANY method found in the Base ORM Service except that you will not pass an argument of entityName anymore as you have now binded to an ORM entity. You can also visit our API for all the methods.
The inheritance is what will make your Entity come alive with tons of useful methods!
This class allows you to simulate the Active Record pattern in your ORM entities by inheriting from our Active Entity class. This will make your ORM entities get all the functionality of our Virtual and Base ORM services so you can do finds, searches, listings, counts, execute queries, transaction safe deletes, saves, updates, criteria building, and even validation right from within your ORM Entity. The idea behind the Active Entity is to allow you to have a very nice abstraction to all the ColdFusion ORM capabilities (hibernate) and all of our ORM extensions like our ColdBox Criteria Builder. With Active Entity you will be able to:
Find entities using a variety of filters and conditions
ORM paging
Specify order, searches, criterias and grouping of orm listing and searches
Use DLM style hibernate operations for multiple entity deletion, saving, and updating
Check for existence of records
Check for counts using criterias
Use our extensive ColdBox Criteria Builder to build Object Oriented HQL queries
Validate your entity using our awesome validation engine
Our active entity object will also give you access to our validation engine by giving your ORM entities the following functions:
Important In order for validation to work, WireBox ORM entity injection must be enabled first!
ColdBox ORM Entity Injection
WireBox Standalone ORM Entity Injection
This makes it really easy for you to validate your ORM entities.
Sample:
Handlers Sample:
Please refer to the ORM:BaseORMService for all the cool methods and functionality you can use with Active Entity. Like always, refer to the latest CFC Docs for methods and arguments.
To work with Active Entity you must do a few things to tell ColdBox you want to use Active Entity and enable validation and injections:
Enable the ORM in your Application.cfc with event handling turned on, manage session and flush at request end as false.
Enable the orm configuration structure in your ConfigurationCFC to allow for ColdBox to do entity injections
You just use entityNew() like you would with any ORM entity and then just call our cool methods:
The following are vanilla configurations for enabling the ORM in ColdFusion:
If you override the constructor in your ORM entity, then make sure that you call the super.init() with the optional arguments below:
queryCacheRegion
string
false
#entityName#.activeEntityCache
The name of the secondary cache region to use when doing queries via this class
useQueryCaching
boolean
false
false
The bit that tells the class to enable query caching, disabled by default
useTransactions
boolean
false
true
The bit that enables automatic hibernate transactions on all save, saveAll, update, delete methods
eventHandling
boolean
false
true
The bit that enables event handling via the ORM Event handler such as interceptions when new entities get created, saved, enabled by default.
defaultAsQuery
boolean
false
true
The bit that determines the default return value for list(), createCriteriaQuery() and executeQuery() as query or array