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

Ortus June 2024 Newsletter!

Ortus June 2024 Newsletter!

Welcome to the latest edition of the Ortus Newsletter! This month, we're excited to bring you highlights from our sessions at CFCamp and Open South Code, as well as a sneak peek into our upcoming events. Discover the latest developments in BoxLang, our dynamic new JVM language, and catch up on all the insightful presentations by our expert team. Let's dive in!

Maria Jose Herrera
Maria Jose Herrera
June 28, 2024
BoxLang June 2024 Newsletter!

BoxLang June 2024 Newsletter!

We're thrilled to bring you the latest updates and exciting developments from the world of BoxLang. This month, we're diving into the newest beta release, introducing a new podcast series, showcasing innovative integrations, and sharing insights from recent events. Whether you're a seasoned developer or just getting started, there's something here for everyone to explore and enjoy.

Maria Jose Herrera
Maria Jose Herrera
June 28, 2024
BoxLang 1.0.0 Beta 3 Launched

BoxLang 1.0.0 Beta 3 Launched

We are thrilled to announce the release of BoxLang 1.0.0-Beta 3! This latest beta version is packed with exciting new features and essential bug fixes, including robust encryption functionality, enhanced Java interoperability, and more efficient event handling. Key highlights include the introduction of query caching capabilities, seamless coercion of Java Single Abstract Method (SAM) interfaces from BoxLang functions, and support for virtual thread executors. So, let’s dive into the details of what’s new in BoxLang 1.0.0-Beta 3 and how you can start leveraging these updates today!

Luis Majano
Luis Majano
June 28, 2024