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

ColdBox 7.2.0 Released

ColdBox 7.2.0 Released

ColdBox, a widely used development platform for ColdFusion (CFML), has unveiled version 7.2. Packed with compelling new features, bug fixes, and enhancements, this release is designed to empower developers by boosting productivity, refining scheduled task capabilities, and enhancing the overall reliability and efficiency of application development. This article will delve into the key highlights of ColdBox 7.2 and elucidate how these advancements can positively impact developers in their daily coding endeavors.

Luis Majano
Luis Majano
November 20, 2023
Into the Box 2023 Series on CFCast

Into the Box 2023 Series on CFCast

Excitement is in the air as we unleash the highly anticipated ITB 2023 series exclusively for our valued CFCast subscribers – and the best part? It's FREE for CFCast members! Now is the perfect time if you haven't joined the CFCast community yet. Plus, we've got an incredible End-of-Year deal that's too good to miss

Maria Jose Herrera
Maria Jose Herrera
November 20, 2023
Ortus Deals are Finally Here!

Ortus Deals are Finally Here!

The much-anticipated Ortus End-of-the-Year Sale has arrived, and it's time to elevate your development experience! Whether you're a seasoned developer, a tech enthusiast, or someone on the lookout for top-notch projects, Ortus has something special in store for you. Brace yourself for incredible discounts across a wide array of products and services, including Ortus annual events, books, cutting-edge services, and more.

Maria Jose Herrera
Maria Jose Herrera
November 15, 2023