So I am working on my abstract service layer and I decided to create a find by method. The idea for this came from a blog post by Joe Rinehart. At the time of writing this his blog was down so I decided to write my own. What this method will allow us to do is provide a generic find by API for our service. Before we get into how it works we should look at what it does. All of my examples are going to use the cfartgallery datasource so you can follow along at home.

In my first example I want to find all art records where the artists name is Michael. We could do something like this. I just think being able to call any field dynamically is just intuitive and let's face it, FUN!
What if we wanted to find all of the paintings in the art table? All of the paintings have a media id of 1. That is pretty easy as well but what if you wanted a query back.
We are not limited to finding by just one property. If we use the AND keyword we can chain together as many properties as we want.

So how does this all work? Well because the method findByMediaIdAndIsSoldAsQuery doesn't actually exist we are going to have to take advantage of the on missing method function. So here is the service component by itself. This is just a small piece of a much bigger abstract service that I am using that I will share with you soon.