openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pinaki Poddar (JIRA)" <j...@apache.org>
Subject [jira] Created: (OPENJPA-1198) Query by Example
Date Mon, 27 Jul 2009 16:28:14 GMT
Query by Example
----------------

                 Key: OPENJPA-1198
                 URL: https://issues.apache.org/jira/browse/OPENJPA-1198
             Project: OpenJPA
          Issue Type: New Feature
          Components: query
            Reporter: Pinaki Poddar
            Assignee: Pinaki Poddar


I am planning to add a new query by example feature to Criteria Query API.

The proposed new method will appear in CriteriaBuilder to create a predicate.
Comments welcome (see below for further details). 

    /**
     * Create a predicate based upon the attribute values of a given
     * "example" entity instance. The predicate is the conjunction 
     * or disjunction of predicates for subset of attribute of the entity.
     * <br>
     * By default, all the singular entity attributes (the basic, embedded
     * and uni-cardinality relations) that have a non-null or non-default
     * value for the example instance and are not an identity or version
     * attribute are included. The comparable attributes can be further
     * pruned by specifying variable list of attributes as the final argument.
     * 
     * @param example an instance of an entity class
     * @param style specifies various aspects of comparison such as whether
     * non-null attribute values be included, how string-valued attribute be 
     * compared, whether the individual attribute based predicates are ANDed
     * or ORed etc.
     *  
     * @return a predicate 
     */
    public <T> Predicate example(From<?, T> expression, T example, ComparisonStyle
style,
        <Attribute<? super T,?>>... excludes) ;
========================================================================
The limitation is that the style is 'global' i.e. applies to all attributes. If we want to
tune comparison style
per attribute, the  API gets somewhat more cumbersome to use. Ideas are welcome.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message