Announcement Announcement Module
Collapse
No announcement yet.
Adding a custom finder breaks GWT requestfactory validation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding a custom finder breaks GWT requestfactory validation

    Hi all,

    I'm getting a error when I do "gwt:run" for the following roo script (adding a finder causes the issue)

    project --topLevelPackage org.springsource.roo.extrack
    jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY

    entity jpa --class ~.server.domain.Employee --testAutomatically
    field string --fieldName displayName --notNull
    field string --fieldName userName --sizeMin 3 --sizeMax 30 --notNull
    field string --fieldName department
    finder add findEmployeesByDepartmentEquals
    web gwt setup
    web gwt all --proxyPackage ~.client.proxy --requestPackage ~.client.request
    logging setup --level INFO

    When I do gwt:run:

    [INFO] [exec:exec {execution: default}]
    warning: Supported source version 'RELEASE_6' from annotation processor 'com.google.web.bindery.requestfactory.apt.RfValid ator' less than -source '1.7'
    error: The type javax.persistence.TypedQuery<org.springsource.roo. extrack.server.domain.Employee> cannot be used here
    warning: Cannot validate this method because the domain mapping for the return type (javax.persistence.TypedQuery<org.springsource.roo .extrack.server.domain.Employee>) could not be resolved to a domain type

    Looking in org.springsource.roo.extrack.client.request.Employ eeRequest, the signature of the finder is

    abstract Request<javax.persistence.TypedQuery<org.springsou rce.roo.extrack.server.domain.Employee>> findEmployeesByDepartmentEquals(String department);

    I guess this should return a List<EmployeeProxy> like the default finders?

    As a workaround I can add the findEmployeesByDepartmentEquals to the "exclude" directive at the top. Is anyone else seeing this issue?

    Env - 2.6.38-8-generic #42-Ubuntu - Roo 1.2.0.RC1 [rev dcaa483]

  • #2
    I get the same issue .

    [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] Building portal
    [INFO] task-segment: [gwt:run]
    [INFO] ------------------------------------------------------------------------
    [INFO] Preparing gwt:run
    [INFO] [aspectj:compile {execution: default}]
    [debug] execute contextualize
    [INFO] [resources:resources {execution: default-resources}]
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 6 resources
    [INFO] [compiler:compile {execution: default-compile}]
    [INFO] Nothing to compile - all classes are up to date
    [INFO] [exec:exec {execution: default}]
    error: The type javax.persistence.TypedQuery<com.powerme.portal.se rver.domain.EzUser> cannot be used here

    Does anybody know why can't it be used here ?
    --
    Pascoual.

    Comment


    • #3
      The probleme is that :
      - Roo make public finders returning TypedQuery<YourEntity> object.
      - GWT YourEntityRequest cannot handle this type in javascript.

      Solution :
      - import finders in YourEntity and make these private.
      - create public finder returning List<YourEntity>
      Roo should remove bad entries in EntityRequest and create new good finder entries.

      --
      Pascoual.

      Comment


      • #4
        Pascoual

        I have also run into this problem and agree to the cause; however, I do not fully understand the solution you have provided. Can you be more explicit as to the classes you are referring to? Are you saying that we should remove the Roo generated finders and insert them into the YourEntity.java class? Where should the public finders be created?

        Thanks for your help!


        Originally posted by Pascoual View Post
        The probleme is that :
        - Roo make public finders returning TypedQuery<YourEntity> object.
        - GWT YourEntityRequest cannot handle this type in javascript.

        Solution :
        - import finders in YourEntity and make these private.
        - create public finder returning List<YourEntity>
        Roo should remove bad entries in EntityRequest and create new good finder entries.

        --
        Pascoual.

        Comment


        • #5
          Originally posted by mmolesworth View Post
          Are you saying that we should remove the Roo generated finders and insert them into the YourEntity.java class?
          Exactly.

          Originally posted by mmolesworth View Post
          Where should the public finders be created?
          In your entity, you can't make modification to Roo ".aj" generated file.

          Example : to put in your entity
          Code:
            
              @SuppressWarnings("unchecked")
              public static User findUserEntryByEmail(String email) {
                  List<User> users = User.findUsersByEmail(email).getResultList();
                  if (users.size() == 1) {
                      return users.get(0);
                  }
                  return null;
              }
              
              private static TypedQuery<User> findUsersByEmail(String email) {
                  if (email == null || email.length() == 0) throw new IllegalArgumentException("The email argument is required");
                  EntityManager em = User.entityManager();
                  TypedQuery<User> q = em.createQuery("SELECT o FROM User AS o WHERE LOWER(o.email) = LOWER(:email)", EzUser.class);
                  q.setParameter("email", email);
                  return q;
              }
          If I'm still not clear, ask .

          --
          Pascoual

          Comment


          • #6
            Thanks Pascoual! This works perfectly. Roo will then automatically push the new finder method out to the RequestContext.

            Comment


            • #7
              Originally posted by Pascoual View Post
              The probleme is that :
              Roo should remove bad entries in EntityRequest and create new good finder entries.
              I cannot get Roo to add methods for dynamic finders in the EntityRequest. See my post here.

              Am I missing something?

              Comment

              Working...
              X