Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] CDO Query which is not DB specific
[CDO] CDO Query which is not DB specific [message #989258] Wed, 05 December 2012 06:36 Go to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 914
Registered: July 2009
Senior Member
Hi,

I think I know the answer, but just to be sure about this. Is there an option to create queries which directly interact with the Store and are not DB vendor specific?
If not, would an OCL query which potentially narrows down a Collection of object, have to fetch all objects from the CDO Server, before applying a restriction?

I am looking for optimizing the roundtrips, and creation of objects, so a way to specify by query, which objects should be created by CDO. At the moment, my code tends to get collections, and apply filters, but this doesn't give the best performance, and also consumes more memory.

Thank You,
Christophe Bouhier


Re: [CDO] CDO Query which is not DB specific [message #989259 is a reply to message #989258] Wed, 05 December 2012 06:42 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal Karaca
Messages: 735
Registered: July 2009
Senior Member
It would be cool to have something similar to JPA's criteria API (see [1] for the EclipseLink impl)
That allows to build queries on domain objects/classes, but later it is all translated to db specific sql.

[1] http://wiki.eclipse.org/EclipseLink/Examples/JPA/2.0/Criteria
Re: [CDO] CDO Query which is not DB specific [message #989417 is a reply to message #989258] Thu, 06 December 2012 02:29 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5499
Registered: July 2009
Senior Member
Am 05.12.2012 12:36, schrieb Christophe Bouhier:
> Hi,
> I think I know the answer, but just to be sure about this. Is there an option to create queries which directly
> interact with the Store and are not DB vendor specific?
By "the store" you mean the DBStore?

The problem with the SQLQueryHandler is (IMHO) not so much that the queries are vDB vendor specific but that they must
be aware of the specific O/R mapping, which is in fact very unfortunate.

Currently I know of no DBStore query handler that interprets the query string in terms of the model and not of the
relational schema. It would be nice to have!

> If not, would an OCL query which potentially narrows down a Collection of object, have to fetch all objects from the
> CDO Server, before applying a restriction?
No, the OCLqueryHandler (which is in fact independent of the store type) operates, like all query handlers, purely on
the server side.

But yes, due to its generic nature, it involves lazy EClass extent iterators, i.e. linear effort. Ed Willink commented
on the performance impact just the other day.

> I am looking for optimizing the roundtrips, and creation of objects, so a way to specify by query, which objects
> should be created by CDO. At the moment, my code tends to get collections, and apply filters, but this doesn't give
> the best performance, and also consumes more memory.
You should try the OCLueryHandler. I have customers that are ry happy with its performance.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] CDO Query which is not DB specific [message #989418 is a reply to message #989259] Thu, 06 December 2012 02:30 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5499
Registered: July 2009
Senior Member
Am 05.12.2012 12:42, schrieb Erdal Karaca:
> It would be cool to have something similar to JPA's criteria API (see [1] for the EclipseLink impl)
> That allows to build queries on domain objects/classes, but later it is all translated to db specific sql.
>
> [1] http://wiki.eclipse.org/EclipseLink/Examples/JPA/2.0/Criteria
That could be a very nice contribution to CDO. I'd be happy to assist and review ;-)

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] CDO Query which is not DB specific [message #989444 is a reply to message #989417] Thu, 06 December 2012 04:20 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 914
Registered: July 2009
Senior Member
Thank you, Eike,

Quote:
By "the store" you mean the DBStore?

By Store, I really mean the underlying persistence system, so RDBMS.
I will look into the various Query handlers, I need to understand better how this works.

My experience sofar with queries is limited, What I have tried sofar is a query which worked on a testbed, but failed on the customer test system.

It had something todo with case sensitive column names. When writing the query, I use mysql command line to test it, than I paste the query in the code, but from your reply I get the impression that the SQL statements are agnostic to the DB vendor? I am not sure what "aware of o/r mapping" means in terms of defining the sql query.

I will certainly have a go at the OCL Query Handler!
Thanks
Christophe
Re: [CDO] CDO Query which is not DB specific [message #989503 is a reply to message #989444] Thu, 06 December 2012 09:26 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5499
Registered: July 2009
Senior Member
Am 06.12.2012 10:20, schrieb Christophe Bouhier:
> Thank you, Eike,
> Quote:
>> By "the store" you mean the DBStore?
>
> By Store, I really mean the underlying persistence system, so RDBMS.
But that's not necessarily an RDBMS in general (see MongoDBStore, ObjectivityStore, DB4OStore, LissomeStore, ...).
Mostly for the DBStore, as I said.

> I will look into the various Query handlers, I need to understand better how this works.
> My experience sofar with queries is limited, What I have tried sofar is a query which worked on a testbed, but failed
> on the customer test system.
> It had something todo with case sensitive column names. When writing the query, I use mysql command line to test it,
> than I paste the query in the code, but from your reply I get the impression that the SQL statements are agnostic to
> the DB vendor? I am not sure what "aware of o/r mapping" means in terms of defining the sql query.
AFAIK the part of SQL that is the most dependent on a vendor is DDL. And that's typically not used in (select) queries.
But, as you said, you need to specifiy table and column names and those depend on the used mapping mechansim, the one
that maps EClasses to tables and EStructuralFeatures to columns (EReferences are handled differently).

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



> I will certainly have a go at the OCL Query Handler! Thanks Christophe
Re: [CDO] CDO Query which is not DB specific [message #990318 is a reply to message #989418] Tue, 11 December 2012 15:01 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal Karaca
Messages: 735
Registered: July 2009
Senior Member
[FYI, for the archives] Just found another framework that could be integrated into CDO:

http://www.querydsl.com/

A JPA criteria like approach, but not bound to JPA.

Eike Stepper wrote on Thu, 06 December 2012 08:30
Am 05.12.2012 12:42, schrieb Erdal Karaca:
> It would be cool to have something similar to JPA's criteria API (see [1] for the EclipseLink impl)
> That allows to build queries on domain objects/classes, but later it is all translated to db specific sql.
>
> [1] http://wiki.eclipse.org/EclipseLink/Examples/JPA/2.0/Criteria
That could be a very nice contribution to CDO. I'd be happy to assist and review Wink

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper

Re: [CDO] CDO Query which is not DB specific [message #990337 is a reply to message #989258] Tue, 11 December 2012 18:17 Go to previous messageGo to next message
Vincenzo Caselli is currently offline Vincenzo Caselli
Messages: 100
Registered: January 2012
Senior Member
Hi all,
so for what I read, given the following requirements

1) server-side execution (i.e. filtering)

2) available with DBStore

3) model-oriented (no "sql"/RDBMS)

OCL Query Language should be a good choice, is this correct ?

Are there alternatives, like for instance a EMF Query/EMF Query2 language implementation?

Thank you
Vincenzo

Re: [CDO] CDO Query which is not DB specific [message #990349 is a reply to message #990337] Wed, 12 December 2012 00:34 Go to previous message
Eike Stepper is currently offline Eike Stepper
Messages: 5499
Registered: July 2009
Senior Member
Am 12.12.2012 00:17, schrieb Vincenzo Caselli:
> Hi all,
> so for what I read, given the following requirements
>
> 1) server-side execution (i.e. filtering)
Yes. allInstances() uses linear scanning.

> 2) available with DBStore
Yes.

> 3) model-oriented (no "sql"/RDBMS)
Yes.

> OCL Query Language should be a good choice, is this correct ?
I think so ;-)

> Are there alternatives, like for instance a EMF Query/EMF Query2 language implementation?
Not that I know of. Well, there is bug 329723: Common Query Language as EMF Query2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=329723

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Previous Topic:[CDO] CDORemoveFeatureDelta does not return removed object
Next Topic:[CDO]Rollback in DBStore NullPointerException
Goto Forum:
  


Current Time: Fri Aug 22 00:12:32 EDT 2014

Powered by FUDForum. Page generated in 0.01771 seconds