Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 322008

Summary: Improve usability of additional criteria applied to queries at the session/EM
Product: z_Archived Reporter: Doug Clarke <douglas.clarke>
Component: EclipselinkAssignee: Guy Pelletier <guy.pelletier>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P2 CC: eclipselink.foundation-inbox, fs5, gordon.yorke, guy.pelletier, karenfbutzke
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
URL: http://wiki.eclipse.org/EclispeLink/Development/AdditionalCriteria
Whiteboard:
Bug Depends on:    
Bug Blocks: 312910    
Attachments:
Description Flags
Proposed changes
none
Updated patch
none
Updated patch
none
testcase for inheritance none

Description Doug Clarke CLA 2010-08-06 11:44:18 EDT
EclipseLInk users can apply addition expressions on mappings and in the default queries of a descriptor as well as modifying queries in events and redirectors. These capabilities allow additional generic 'filtering' of query results to be applied. 

This enhancement will simplify the usage of these capabilities enabling these 'filters' to be more easily defined and used.
Comment 1 Guy Pelletier CLA 2010-10-08 11:34:16 EDT
Created attachment 180495 [details]
Proposed changes
Comment 2 Guy Pelletier CLA 2010-10-13 15:31:10 EDT
Created attachment 180817 [details]
Updated patch

After review from Gordon and James.
Comment 3 Guy Pelletier CLA 2010-10-15 15:07:06 EDT
Created attachment 181006 [details]
Updated patch

Patch updated after review from Gordon.
Comment 4 Guy Pelletier CLA 2010-10-15 15:24:18 EDT
Changes have been submitted.

Reviewed by: Gordon Yorke, James Sutherland

Add new additional criteria model (annotations and XML) and new tests to AdvancedJPAJunitTest and EntityMappingsAdvancedJUnitTestCase. 

- testAdditionalCriteriaModelPopulate
- testAdditionalCriteria
- testAdditionalCriteriaWithParameterFromEM1
- testAdditionalCriteriaWithParameterFromEM2
- testAdditionalCriteriaWithParameterFromEMF
- testComplexAdditionalCriteria
Comment 5 Frank Schwarz CLA 2010-10-16 06:31:45 EDT
The name @AdditionalCriteria is somewhat misleading as it is fundamentally JPQL and not (JPA-)Criteria. Would not just "@Restriction" or have been more appropriate?

And more importantly: Is inheritance addressed as well?

@AdditionalCriteria("this.deleted = false")
public class Person { }

@AdditionalCriteria("this.active = true")
public class Employee extends Person {}


And, this feature/annotation would suit associations also very well:

@OneToMany
@ReadOnly
@Restriction("project.active = true and project.dueDate < CURRENT_DATE")
private List<Project> overdueProjects
Comment 6 Frank Schwarz CLA 2010-10-16 06:35:38 EDT
Created attachment 181034 [details]
testcase for inheritance

Inheritance should be supported or otherwise there should be a validation exception while bootstrapping the EMF.

Model of the test case:

@AdditionalCriteria("this.deleted = false")
public class Person { }

@AdditionalCriteria("this.active = true")
public class Employee extends Person {}
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:10:12 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink