Issue Details (XML | Word | Printable)

Key: JDO-448
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Michelle Caisse
Reporter: Michelle Caisse
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JDO

Add an xml element to specify the fetch plan to use for a query

Created: 08/Dec/06 11:21 PM   Updated: 09/Jan/08 11:37 PM
Return to search
Component/s: api2, api2-legacy, specification
Affects Version/s: JDO 2 final
Fix Version/s: JDO 2 maintenance release 1

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works jdo-448.patch 2007-12-18 05:41 PM Michelle Caisse 6 kB

Resolution Date: 09/Jan/08 11:37 PM


 Description  « Hide
In Chapter 18, add an xml element to specify the fetch plan to use for a query.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Craig Russell made changes - 09/Dec/06 11:49 PM
Field Original Value New Value
Fix Version/s JDO 2 maintenance release 1 [ 12310923 ]
Craig Russell made changes - 10/Dec/06 12:16 AM
Component/s specification [ 12311332 ]
Craig Russell added a comment - 19/Oct/07 10:40 PM
There are a couple of ways to handle this issue.

1. Add element fetch-group*, and attributes max-fetch-depth, fetch-size to element query. These are used to set the FetchPlan in the stored query.

<query name="BySalary" max-fetch-depth="3" fetch-size="17">
  <fetch-group name="default"/>
  <fetch-group name="images"/>
SELECT THIS from Employee WHERE salary == :salary
</query>

2. Add a new fetch-plan element that contains fetch-group* and attributes name, max-fetch-depth, fetch-size. Add attribute fetch-plan to element query.

<fetch-plan name="EmployeeImages" max-fetch-depth="3" fetch-size="17">
  <fetch-group name="default"/>
  <fetch-group name="images"/>
</fetch-plan>

<query name="BySalary" fetch-plan="EmployeeImages">
SELECT THIS from Employee WHERE salary == :salary
</query>

3. Add a new fetch-plan element that contains fetch-group* and attributes max-fetch-depth, fetch-size. Add element fetch-plan to element query.

<query name="BySalary">
<fetch-plan name="EmployeeImages" max-fetch-depth="3" fetch-size="17">
  <fetch-group name="default"/>
  <fetch-group name="images"/>
</fetch-plan>
SELECT THIS from Employee WHERE salary == :salary
</query>

I like the idea of named fetch plans because the same fetch plan could then be used in multiple queries. Also, I think there is value in being able to specify declaratively what a fetch plan is, without having to use an API to declare it. We could use this in other places in the spec.

So I'm leaning toward option 2.

Craig Russell made changes - 19/Oct/07 11:24 PM
Status Open [ 1 ] In Progress [ 3 ]
Michelle Caisse added a comment - 09/Nov/07 07:10 PM
I also like being able to define a named fetch-plan. This works well with xml metadata where you can nest a fetch-plan element under <jdo>, but with annotations you would have to apply the @FetchPlan annotation to a class or interface, while the intent is for the scope to be global.

Craig Russell made changes - 07/Dec/07 11:21 PM
Assignee Craig Russell [ clr ] Michelle Caisse [ mcaisse ]
Michelle Caisse added a comment - 15/Dec/07 05:05 AM
The attached patch adds an annotation and xml schema for a named fetch plan. The annotation applies to a type and the xml metadata is nested within the jdo element. I did not add fetch-plan the jdoquery schema because that would have required adding fetch-group to the schema, which in turn would have required adding field, property, ...

Michelle Caisse made changes - 15/Dec/07 05:05 AM
Attachment jdo-448.patch [ 12371718 ]
Andy Jefferson added a comment - 17/Dec/07 02:24 PM
Why not add @FetchPlans too, in the same style as @FetchGroups ? Would mean that a class could define multiple fetch plans, rather than being limited to a single one.

Andy Jefferson added a comment - 17/Dec/07 05:26 PM
@FetchPlan : The default for "maxFetchDepth" should be 1, and the default for fetchSize should be 0 (FETCH_SIZE_OPTIMAL) for consistency with javax.jdo.FetchPlan

Michelle Caisse added a comment - 18/Dec/07 12:50 AM
Thanks for the comments Andy. I've attached a patch with the changes.

Michelle Caisse made changes - 18/Dec/07 12:50 AM
Attachment jdo-448.patch [ 12371838 ]
Michelle Caisse made changes - 18/Dec/07 12:50 AM
Attachment jdo-448.patch [ 12371718 ]
Andy Jefferson added a comment - 18/Dec/07 08:49 AM
Michelle, looks good, except the @FetchPlan annotation has the defaults reversed from my comment above.

Andy Jefferson added a comment - 18/Dec/07 09:25 AM
Also @Query will need an attribute "fetchPlan" to allow the same as <query fetch-plan="...">

Craig Russell added a comment - 18/Dec/07 05:12 PM
The xsd patch will apply to both api2 and api2-legacy.

Michelle Caisse added a comment - 18/Dec/07 05:41 PM
New patch with latest fixes attached.

Michelle Caisse made changes - 18/Dec/07 05:41 PM
Attachment jdo-448.patch [ 12371884 ]
Michelle Caisse made changes - 18/Dec/07 05:41 PM
Attachment jdo-448.patch [ 12371838 ]
Craig Russell added a comment - 18/Dec/07 06:04 PM
Looks good.

The comment
+/**
+ * Annotation for a group of fetch-group objects
+ *
+ * @version 2.1
+ * @since 2.1

Should refer to a group of FetchPlan not fetch-group.

Repository Revision Date User Message
ASF #605287 Tue Dec 18 18:35:13 UTC 2007 mcaisse JDO-448
Files Changed
ADD /db/jdo/trunk/api2/src/java/javax/jdo/annotations/FetchPlans.java
MODIFY /db/jdo/trunk/api2/src/java/javax/jdo/annotations/Query.java
ADD /db/jdo/trunk/api2/src/java/javax/jdo/annotations/FetchPlan.java
MODIFY /db/jdo/trunk/api2/src/schema/javax/jdo/jdo_2_1.xsd

Craig Russell added a comment - 18/Dec/07 06:38 PM
+ /**
+ * The fetch groups in this fetch plan.
+ * @return the fetch groups
+ */
+ String[] fetchGroups() default "";

The default should be [ ] not "".


Repository Revision Date User Message
ASF #605291 Tue Dec 18 18:46:57 UTC 2007 mcaisse JDO-448
Files Changed
MODIFY /db/jdo/trunk/api2-legacy/src/schema/javax/jdo/jdo_2_1.xsd

Repository Revision Date User Message
ASF #605294 Tue Dec 18 18:58:27 UTC 2007 mcaisse JDO-448
Files Changed
MODIFY /db/jdo/trunk/api2/src/java/javax/jdo/annotations/FetchPlan.java

Michelle Caisse made changes - 09/Jan/08 11:37 PM
Resolution Fixed [ 1 ]
Status In Progress [ 3 ] Resolved [ 5 ]