Reputation: 2565
I want to create a complex custom finder and generate jspx file for it.
I have a class called Payment that was generated by spring ROO (please note that actual code was modified in order to simplify things):
package com.mystuff.orm;
...
@RooJavaBean
@RooToString
public class Payment {
private Double someValue;
...
// My Custom finder!!
public static TypedQuery<PaymentSummary> findPaymentStatistics(Calendar fromDate, Calendar toDate) {
if (fromDate == null || toDate == null)
throw new IllegalArgumentException("Date period argument is required");
EntityManager em = Payment.entityManager();
TypedQuery<PaymentSummary> q = em.createQuery("select new com.mystuff.data.PaymentSummary(sum(o.someValue)) from Payment o where o.startDate >= :startDate and o.endDate <= :endDate", PaymentSummary.class);
q.setParameter("startDate", fromDate);
q.setParameter("endDate", toDate);
return q;
}
}
How can I generate jspx files for this query? Whenever I try to run "finder add --finderName findPaymentStatistics" I get an error message:
Dynamic finder is unable to match 'findPaymentStatistics' token of 'findPaymentStatistics' finder definition in Payment.java
Any ideas?
Thanks
Upvotes: 0
Views: 1219
Reputation: 2092
Is 'findPaymentStatistics' above is a method you implemented by hand? If so, then Roo won't be able to generate the front end for it. However, Roo will generate a front end if you have it create the finder code itself. Roo should be able to generate a similar finder to the one you've coded by hand. Try running this:
roo> finder list --class com.mystuff.orm.Payment --filter start,end
That should give you a list of the dynamic finders that Roo can create that include the 'startDate' and 'endDate' parameters of the Payment object.
Upvotes: 1