Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EclipseLink/Development/AdditionalCriteria

< EclipseLink‎ | Development
Revision as of 11:20, 20 September 2010 by Unnamed Poltroon (Talk) (Additional Criteria Requirements and Design)

Additional Criteria Requirements and Design

Enhancement Request: bug 322008

Additional criteria can be overriden from the eclipselink-orm.xml. The eclipselink-orm.xml will override annotations and other xml mapping files)

XML file merging will remain in place as well.

E.G.

mapping.xml defines <additional-criteria> - overriden and ignored
eclipselink.xml defines <additional-criteria-group> - applied

Added to <entity> and <mapped-superclass>

 <xsd:choice minOccurs="0">
   <xsd:element name="additional-criteria" type="orm:additional-criteria"/>
   <xsd:element name="additional-criteria-group" type="orm:additional-criteria-group"/>
   <xsd:element name="additional-criteria-callback" type="orm:additional-criteria-callback"/>
 </xsd:choice>

Sample Usage

The following is an initial proposal to generate discussion.

@Entity
 
// This annotation is needed and very useful when defining comparison against 
// columns that are not mapped
@BasicQueryAttribute(name = "isDeleted", column = @Column(name = "IS_DEL"))
 
/**
 *  Simple fixed criteria for virtual delete scenario
 */
@FixedCriteria(attribute = "isDeleted", operator = EQUAL, value = "Y")
 
/**
 *  Simple Property usage. The property will be looked up in the active session
 *  
 *  Note: Currently this is only the UOW/CS when the cache.shared=false. When cache.shared=true only the server session's properties are visible.
 */
@PropertyCriteria(attribute = "company", operator = LIKE, property = "COMPANY_PATTERN")
 
/**
 * Call-back criteria where expressions can be added dynamically. This class
 * could either implement an interface for call-backs or an additional set of
 * annotations could be defined that allows you to define which methods are
 * called for which query types.
 */
@CallbackCriteria(CustomerUserCriteria.class)
 
/**
 * More complex additional criteria that supports composition, named access, and 
 * enable/disable. Any of the above could be specified within @AdditionalCriteria to 
 * allow enable/disable through named access.
 * 
 * When specified without @AdditionalCriteria all of the provided criteria are combined 
 * into a AdditionalCriteria named 'default' on the descriptor and enabled.
 */
@AdditionalCriteria(name = "example", enabled = false, 
        fixed = { @FixedCriteria(attribute = "name", operator = NOT_NULL) }, 
        properties = { @PropertyCriteria(attribute = "company", operator = EQUAL, property = "COMPANY_NAME") }, 
        callbacks = { @CallbackCriteria(CustomerTemporalCriteria.class) })
public class Customer {
 
    @Id
    private int id;
 
    private String name;
 
    private String company;

Back to the top