Blog

Brad Wood

October 10, 2012

Spread the word


Share your thoughts

 

Dynamic Finders are brand new to ColdBox 3.5.3 which will be released shortly.  I usually give tips on released functionality, but we're real excited about our new Grails-inspired functionality and invite you to check it out on our development line to give them a spin.
 
Dynamic Finders basically let you create very readable code with dynamic method names that describe the criteria being used to to load or count ORM entities.  The best part is, you don't have to write any of the code-- just call the dynamic method and ColdBox does the rest!
 
Any ColdFusion ORM entity that extends our ActiveEntity component as well as any base or virtual entity service will all support these dynamic finder methods.  Each method must start with "findBy", "findAllBy", or "countBy" and can contain any number of properties and conditionals.
 
Here's some examples:
user = entityNew("User").findByLastName("Majano");
users = entityNew("User").findAllByLastNameLike("Ma%");

property name="userService" inject="entityservice:userService";
users = userService.findAllByLastLoginBetween( "01/01/2010", "01/01/2012" );
users = userService.findAllByLastLoginGreaterThan( "01/01/2010" );
count = userService.countByLastLoginGreaterThanAndLastNameLike( "01/01/2010", "jo%");
 
Super easy, right?  Download the bleeding edge now to play with them!  (https://github.com/ColdBox/coldbox-platform/zipball/development)
 
Here's a quick demo from today's ColdBox Connection meeting: http://experts.adobeconnect.com/p6byoxrm7aa/
 
P.S. You can still have control over things such as your query's maxResults and offset by passing a struct of settings in as the last parameter to your dynamic method.
 

 

Add Your Comment

Recent Entries

Hackers demand a ransom to restore data from my ColdFusion web applications!

Hackers demand a ransom to restore data from my ColdFusion web applications!

Hackers demand a ransom to restore data from my ColdFusion web applications!

Unfortunately, we often hear this message from clients who thought it would never happen to them... until it did. Some believed they could delay the expense of Implementing ColdFusion security best practices for one year, while others were tempted to put it off for just a few months. However, in today's rapidly evolving digital landscape, the security of web applications, including ColdFusio...

Cristobal Escobar
Cristobal Escobar
April 16, 2024
Ortus March Newsletter

Ortus March Newsletter

Welcome to Ortus Solutions’ monthly roundup, where we're thrilled to showcase cutting-edge advancements, product updates, and exciting events! Join us as we delve into the latest innovations shaping the future of technology.

Maria Jose Herrera
Maria Jose Herrera
April 01, 2024
Into the Box 2024 Last Early Bird Days!

Into the Box 2024 Last Early Bird Days!

Time is ticking, with less than 60 days remaining until the excitement of Into the Box 2024 unfolds! Don't let this golden opportunity slip away; our exclusive Early Bird Pricing is here for a limited time only, available until March 31st. Why wait? Secure your seat now and take advantage of this steal!

Maria Jose Herrera
Maria Jose Herrera
March 20, 2024