Announcement Announcement Module
No announcement yet.
Spring ROO - Generate jspx files for custom finders Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring ROO - Generate jspx files for custom finders

    I have a class called Payment that was generated by spring ROO, and I would like to create a "custom" finder ("complex" finder that returns aggregated results) and use Spring ROO's mechanism to generate the jspx files etc. Is this possible?

    My code (modified for the question):
    package com.mystuff.orm;
    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 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
    Thanks for the help,

  • #2
    Please use the 'finder list' command to see which exact finder names are acceptable for Roo.



    • #3
      Thanks Stefan,

      I know that my finder is not in the finders list, but I was still wondering if there is a way to handle custom finders that were not generate by roo or a way to add my finder to the finders list.



      • #4
        Roo needs to use the finder names it can reason about so it can generate the correct forms for it. So you can't just add a custom finder name and hope Roo can do black magic . However, you can use a known finder name (findBy..DateBetween) which Roo can offer views for and then push it in to customize the SQL statement.

        Alternatively, you can create your own jspx (using Roos tags if you want) to get your custom finder working.



        • #5
          Thanks Stefan, I'll do as you suggested.


          • #6
            How come when using the finder add and supplying a finder name from the list, sometimes it creates it properly with the aspect, and sometimes it just updates the Entity and does not create the aspect. It seems sproadic.


            • #7
              Can you please try one of the latest snapshot releases to see if this behaviour is still present?

              We recently made a number of changes to address this issue. If the problem still persists, please open a Jira bug ticket.


              • #8
                Well, I downloaded it and unzipped it. Added the version to the Spring Roo Support Workspace settings. Getting these pom errors:
                2/3/11 4:06:41 PM MST: [WARN] The POM for notations:jar:1.1.2.BUILD-SNAPSHOT is missing, no dependency information available
                2/3/11 4:06:41 PM MST: Maven Builder: AUTO_BUILD
                2/3/11 4:08:20 PM MST: [WARN] The POM for notations:jar:1.1.2.BUILD-SNAPSHOT is missing, no dependency information available
                2/3/11 4:08:20 PM MST: Missing artifact notations:jar:1.1.2.BUILD-SNAPSHOTrovided
                2/3/11 4:08:21 PM MST: Maven Builder: AUTO_BUILD


                • #9
                  Had to change the pom file annotations version to: 1.1.1.RELEASE


                  • #10
                    Had to update the pom file <artifactId>org.springframework.roo.annotations</artifactId>

                    It seems to have removed all the current finders and does nothing when doing a finder add or a finder list.