At the moment, Roo can only generate single-entity finders, e.g. in the "Pet Clinic" sample application, you can generate "findPetsByNameEquals(String name)" and "findPetsByOwner(Owner owner)", but not "findPetsByOwnerFirstNameEquals(String firstName)". Multi-entity finders are definitely on our radar, in fact we were only talking at lunch today about how the shell commands might look.
Anyway, the easiest way to generate a custom finder in the current release is to:
- Use the "finder list" and "finder add" commands to generate a built-in finder that goes some way towards what you want (or use this tip if you want to query by lots of fields).
- "Push" that finder into your entity class either by:
- Using your IDE's AspectJ plugin (e.g. the one available for Eclipse, installed by default in STS), or
- Copying-and-pasting it from the Blah_Roo_Finder.aj file into your entity class (using any text editor you like) and fixing the compile errors in that class (Roo will fix the .aj file itself next time you run the shell)
- Modify the pushed-in finder's JPQL query to meet your needs (which being standard JPA is outside the scope of this forum).
Hopefully this is enough to get you started?
Andrew Swan
"Now is the EJB of our discontent made glorious Spring"