AppFuse
  1. AppFuse
  2. APF-924

Poorman's dynamic finder: findAllWhere(....)

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0 Final
    • Fix Version/s: 2.1.0
    • Component/s: Persistence Layer
    • Labels:
      None

      Description

      A finder impl to DaoImpls that can handle majority of findAllWhere(conditions...) that is similar but more flexible than query by example that can handle:

      /**

      • Generic method to get a list of objects based on class and constraints as a Map of:
      • <ul>
      • <li>HQL property path expression 1 as String -> null | Object | Object[] | Collection
      • <li>HQL property path expression 2 as String -> null | Object | Object[] | Collection
      • <li>...
      • </ul>
      • Note that:
      • <ul>
      • <li>Each Map entry translate to a predicate that must be satisfied, i.e. all entries are to be 'AND'd together
      • <li>if entry.value is null, the HQL criteria translates to isNull
      • <li>if entry.value is Object, the HQL criteria translates to isEqualTo
      • <li>if entry.value is Object[] or Collection, the HQL criteria translates to isOneOf
      • <li>if entry.key starts with "!", the HQL criteria translates to isNot
      • <li>if entry.key ends with "~", the HQL criteria translates to isLike
      • <li>if entry.key ends with ">", the HQL criteria translates to isGreaterThan
      • <li>if entry.key ends with ">=", the HQL criteria translates to isGreaterThanOrEqualTo
      • <li>if entry.key ends with "<", the HQL criteria translates to isLessThan
      • <li>if entry.key ends with "<=", the HQL criteria translates to isLessThanOrEqualTo
      • </ul>
      • Example: find all Users whose first name is Brian, last name starts with G, and age between 30 and 40
      • find(User.class, { "firstName":"Brian", "lastName~":"G%", "age>=":30, "age<":40 }

        )

      • @param clazz model class to lookup
      • @param Map specifying the constraints
      • @return List of populated object satisfying constraints
      • @see org.springframework.orm.ObjectRetrievalFailureException
        */
        public List<T> find(Map<String,Object> constraints);

      /**

      • Extending find(Class,Map) to handle Several Constraint Sets, only one ConstraintSet need to match
      • i.e. Disjunctive Normal Form
      • @param clazz
      • @param constraintSets
      • @return List of populated object satisfying at least one of the constraintSets
        */
        public List<T> find(Map<String,Object>[] constraintSets);

        Activity

        Brian Guan created issue -
        Matt Raible made changes -
        Field Original Value New Value
        Fix Version/s 2.1 [ 10031 ]
        Matt Raible made changes -
        Fix Version/s 2.1.0-M2 [ 10210 ]
        Fix Version/s 2.1.0-M1 [ 10031 ]
        Matt Raible made changes -
        Fix Version/s 2.1.0 [ 10211 ]
        Fix Version/s 2.1.0-M2 [ 10210 ]
        Hide
        Matt Raible added a comment -

        I believe using Compass for fancy queries is better than adding this functionality. This was added last week with APF-267.

        Show
        Matt Raible added a comment - I believe using Compass for fancy queries is better than adding this functionality. This was added last week with APF-267 .
        Matt Raible made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Matt Raible
            Reporter:
            Brian Guan
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development