Results 1 to 10 of 10

Thread: Spring ROO - Generate jspx files for custom finders

  1. #1
    Join Date
    Jan 2011
    Posts
    3

    Default 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):
    Code:
    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
    Thanks for the help,
    Li

  2. #2
    Join Date
    Mar 2008
    Location
    Sydney, AU
    Posts
    974

    Default

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

    HTH,
    Stefan
    Stefan Schmidt
    Software Engineer, Spring Roo
    SpringSource - a division of VMware
    twitter @schmidtstefan

  3. #3
    Join Date
    Jan 2011
    Posts
    3

    Default

    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.

    Thanks,
    Lin

  4. #4
    Join Date
    Mar 2008
    Location
    Sydney, AU
    Posts
    974

    Default

    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.

    -Stefan
    Stefan Schmidt
    Software Engineer, Spring Roo
    SpringSource - a division of VMware
    twitter @schmidtstefan

  5. #5
    Join Date
    Jan 2011
    Posts
    3

    Default

    Thanks Stefan, I'll do as you suggested.

  6. #6
    Join Date
    Jan 2011
    Posts
    7

    Default

    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. #7
    Join Date
    Mar 2008
    Location
    Sydney, AU
    Posts
    974

    Default

    Can you please try one of the latest snapshot releases to see if this behaviour is still present? http://static.springsource.org/downl...hp?project=ROO

    We recently made a number of changes to address this issue. If the problem still persists, please open a Jira bug ticket.
    Stefan Schmidt
    Software Engineer, Spring Roo
    SpringSource - a division of VMware
    twitter @schmidtstefan

  8. #8
    Join Date
    Jan 2011
    Posts
    7

    Default

    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 org.springframework.roo:org.springframework.roo.an 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 org.springframework.roo:org.springframework.roo.an notations:jar:1.1.2.BUILD-SNAPSHOT is missing, no dependency information available
    2/3/11 4:08:20 PM MST: Missing artifact org.springframework.roo:org.springframework.roo.an notations:jar:1.1.2.BUILD-SNAPSHOTrovided
    2/3/11 4:08:21 PM MST: Maven Builder: AUTO_BUILD

  9. #9
    Join Date
    Jan 2011
    Posts
    7

    Default

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

  10. #10
    Join Date
    Jan 2011
    Posts
    7

    Default

    Had to update the pom file <artifactId>org.springframework.roo.annotations</artifactId>
    <version>1.1.1.RELEASE</version>

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •