JDO2.1/2.2 Proposal : Dynamic Fetch Groups
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache JDO Project > JDO2.1/2.2 Proposal : Dynamic Fetch Groups




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    JDO2.1/2.2 Proposal : Dynamic Fetch Groups  
Andy Jefferson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-13-07 12:11 PM

Below is a proposal that could possibly be included in a JDO2.2 (or in JDO2=
=2E1=20
if feedback is positive for that, and JPOX already implements it).

 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D
Problem : fetch groups are static, defined in metadata (XML/annotations). =
=20
Sometimes it would be more convenient to be able to define fetch groups =20
dynamically, for example based on user interaction in a web system.

 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D
Proposal :
We add a new interface defining a FetchGroup, where a FetchGroup has a =20
symbolic name and is for a class defining the fields of that class that are=
=20
in the fetch group.

public interface FetchGroup
{
String getName(); // Symbolic name (as also used in MetaData)
String getClassName(); // Class to which this group refers
FetchGroup add(String fieldName); // Add a field
FetchGroup remove(String fieldName); // Remove a field

boolean hasField(String fieldName);
String[] getFieldNames();

void setPostLoad(boolean postLoad);
boolean getPostLoad();
}

We allow users to register/deregister their FetchGroups with the PMF

PersistenceManagerFactory
{
..
void addFetchGroup(FetchGroup grp);
void removeFetchGroup(String name, Class cls);
FetchGroup createFetchGroup(String name, Class cls);
FetchGroup getFetchGroup(String grpName, Class cls);
FetchGroup[] getFetchGroups();
void clearFetchGroups();
}

 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D
Usage:
=46etchGroup grp1 =3D pmf.createFetchGroup("myGroup1", MyClass.class);
grp1.add("field1").add("field2").add("field4");
pmf.addFetchGroup(grp1); // FetchGroup registered

pm.getFetchPlan().setGroup("myGroup1"); // FetchGroup used in this plan
// FetchPlan now has MyClass {field1, field2, field4}

We can then also allow dynamic changes like
pmf.getFetchGroup("myGroup1", MyClass.class).add("field7");
and this is directly reflected in the FetchPlan



Possible changes:-
1. PMF has createFetchGroup and addFetchGroup and we could merge these so w=
hen=20
creating a FetchGroup it is added
2. Doesnt support "recursion-depth" specification when adding a field to a=
=20
=46etchGroup, so we could add a method "add(String fieldName, int depth)"


=2D-=20
Andy =C2=A0(Java Persistent Objects - http://www.jpox.org)






[ Post a follow-up to this message ]



    RE: JDO2.1/2.2 Proposal : Dynamic Fetch Groups  
Eric Samson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-13-07 12:11 PM

Hi Andy,

 

This is a good initiative, thank you.

JDO 2 needs alternate ways to define fetch plans.

 

Some food for thoughts here:

·         possibility to add the DFG of a class into a fetch group

·         possibility to add all fields of a class into a fetch group

·         possibility to add all primitive fields of a class into a fetch g
roup

·         possibility to add all reference fields of a class into a fetch g
roup

·         possibility to add all collections fields of a class into a fetch
 group

·         possibility to remove all primitive fields of a class into a fetc
h group

·         possibility to remove all reference fields of a class into a fetc
h group

·         possibility to remove all collections fields of a class into a fe
tch group

·         possibility to create a global fetch plan without fetch groups at
 all

 

pm.setFetchPlan( "Person(             name,age, 

address( {dfg} ,

                 country( {all} , -flagIMG ) ), 

accounts( {simple} , +{references} )           )"   ) ;

 

Person actually references the candidate class, so I suppose it could be opt
ional.

 

This method will load name and age from a Person, then will load the configu
red DFG from the reference to Address, then will load all fields but flagIMG
 from the reference to Country into address, and finally will load simple fi
elds and unary references to other objects from the collection of Accounts. 
We should also probably support depth in that mechanism.

 

Having this “SSFP” (Single String Fetch Plan) will allow to tune the sys
tem externally, from JMX or a configuration file for instance.

 

Many users told me it is quite difficult to define fetch plans from independ
ent fetch groups configured in various classes (and possibly various JDO fil
es). They would like a way to execute a query with a fetch plan defined next
 to the query, by APIs, or by configuration.

 

Just my 2 cents.

 

Rgds,

...: Eric Samson, Founder & CTO, Xcalia

Service your Data!

 

-----Message d'origine-----
De : Andy Jefferson [mailto:andy@jpox.org] 
Envoyé : mardi 13 novembre 2007 11:33
À : jdo-dev@db.apache.org; JDO Expert Group
Objet : JDO2.1/2.2 Proposal : Dynamic Fetch Groups

 

Below is a proposal that could possibly be included in a JDO2.2 (or in JDO2.
1 

if feedback is positive for that, and JPOX already implements it).

 

 ========================================


Problem : fetch groups are static, defined in metadata (XML/annotations).  

Sometimes it would be more convenient to be able to define fetch groups  

dynamically, for example based on user interaction in a web system.

 

 ========================================


Proposal :

We add a new interface defining a FetchGroup, where a FetchGroup has a  

symbolic name and is for a class defining the fields of that class that are 
 

in the fetch group.

 

public interface FetchGroup

{

    String getName(); // Symbolic name (as also used in MetaData)

    String getClassName(); // Class to which this group refers

    FetchGroup add(String fieldName); // Add a field

    FetchGroup remove(String fieldName); // Remove a field

 

    boolean hasField(String fieldName);

    String[] getFieldNames();

 

    void setPostLoad(boolean postLoad);

    boolean getPostLoad();

}

 

We allow users to register/deregister their FetchGroups with the PMF

 

PersistenceManagerFactory

{

    ...

    void addFetchGroup(FetchGroup grp);

    void removeFetchGroup(String name, Class cls);

    FetchGroup createFetchGroup(String name, Class cls);

    FetchGroup getFetchGroup(String grpName, Class cls);

    FetchGroup[] getFetchGroups();

    void clearFetchGroups();

}

 

 ========================================


Usage:

FetchGroup grp1 = pmf.createFetchGroup("myGroup1", MyClass.class);

grp1.add("field1").add("field2").add("field4");

pmf.addFetchGroup(grp1); // FetchGroup registered

 

pm.getFetchPlan().setGroup("myGroup1"); // FetchGroup used in this plan

// FetchPlan now has MyClass {field1, field2, field4}

 

We can then also allow dynamic changes like

pmf.getFetchGroup("myGroup1", MyClass.class).add("field7");

and this is directly reflected in the FetchPlan

 

 

 

Possible changes:-

1. PMF has createFetchGroup and addFetchGroup and we could merge these so wh
en 

creating a FetchGroup it is added

2. Doesnt support "recursion-depth" specification when adding a field to a 

FetchGroup, so we could add a method "add(String fieldName, int depth)"

 

 

-- 

Andy  (Java Persistent Objects - http://www.jpox.org)






[ Post a follow-up to this message ]



    Re: JDO2.1/2.2 Proposal : Dynamic Fetch Groups  
Matthew Adams


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-14-07 12:11 AM

You might also consider overloaded methods on interface FetchGroup,
just for completeness:

// (importing java.lang.reflect.Field)

FetchGroup add(Field field);
FetchGroup remove(Field field);
boolean hasField(Field field); // or has(Field) -- I'd consider
better verb
Field[] getFields();

The add & remove methods should throw if the Field isn't contained in
the class.

-matthew

On Nov 13, 2007, at 2:32 AM, Andy Jefferson wrote:

> Below is a proposal that could possibly be included in a JDO2.2 (or
> in JDO2.1
> if feedback is positive for that, and JPOX already implements it).
>
>  ========================================

> Problem : fetch groups are static, defined in metadata (XML/
> annotations).
> Sometimes it would be more convenient to be able to define fetch
> groups
> dynamically, for example based on user interaction in a web system.
>
>  ========================================

> Proposal :
> We add a new interface defining a FetchGroup, where a FetchGroup has a
> symbolic name and is for a class defining the fields of that class
> that are
> in the fetch group.
>
> public interface FetchGroup
> {
>     String getName(); // Symbolic name (as also used in MetaData)
>     String getClassName(); // Class to which this group refers
>     FetchGroup add(String fieldName); // Add a field
>     FetchGroup remove(String fieldName); // Remove a field
>
>     boolean hasField(String fieldName);
>     String[] getFieldNames();
>
>     void setPostLoad(boolean postLoad);
>     boolean getPostLoad();
> }
>
> We allow users to register/deregister their FetchGroups with the PMF
>
> PersistenceManagerFactory
> {
>     ...
>     void addFetchGroup(FetchGroup grp);
>     void removeFetchGroup(String name, Class cls);
>     FetchGroup createFetchGroup(String name, Class cls);
>     FetchGroup getFetchGroup(String grpName, Class cls);
>     FetchGroup[] getFetchGroups();
>     void clearFetchGroups();
> }
>
>  ========================================

> Usage:
> FetchGroup grp1 = pmf.createFetchGroup("myGroup1", MyClass.class);
> grp1.add("field1").add("field2").add("field4");
> pmf.addFetchGroup(grp1); // FetchGroup registered
>
> pm.getFetchPlan().setGroup("myGroup1"); // FetchGroup used in this
> plan
> // FetchPlan now has MyClass {field1, field2, field4}
>
> We can then also allow dynamic changes like
> pmf.getFetchGroup("myGroup1", MyClass.class).add("field7");
> and this is directly reflected in the FetchPlan
>
>
>
> Possible changes:-
> 1. PMF has createFetchGroup and addFetchGroup and we could merge
> these so when
> creating a FetchGroup it is added
> 2. Doesnt support "recursion-depth" specification when adding a
> field to a
> FetchGroup, so we could add a method "add(String fieldName, int
> depth)"
>
>
> --
> Andy  (Java Persistent Objects - http://www.jpox.org)







[ Post a follow-up to this message ]



    Re: JDO2.1/2.2 Proposal : Dynamic Fetch Groups  
Christiaan


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-19-07 06:12 PM


Good idea, I've already been needing this.

May be also think about an option to restore to a fetchGroup to a state
before you start changing it (possibly via supporting clone()) or reset to
configuration defined in JDO file.

kind regards,
Christiaan
--
View this message in context: http://www.nabble.com/JDO2.1-2.2-Pr....html#a13839872
Sent from the JDO - Development mailing list archive at Nabble.com.







[ Post a follow-up to this message ]



    Re: JDO2.1/2.2 Proposal : Dynamic Fetch Groups  
Craig L Russell


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-19-07 06:12 PM






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 10:43 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register