Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Backends and query languages
[CDO] Backends and query languages [message #857347] Thu, 26 April 2012 13:23 Go to next message
Guido Scalise is currently offline Guido ScaliseFriend
Messages: 16
Registered: April 2012
Junior Member
I'm considering CDO v4.0 for a new project where I will need to intensively use queries and audit views.

I started investigating OCL as a query language, but while I found it to be very powerful in several aspects, I also find it somewhat limited for some of the queries I will need to run, and I know they could be implemented very easily in HQL. The problem is that I've read in the CDO Hibernate Store documentation that the Hibernate store doesn't support audit views, so AFAIK, I'm stuck with OCL.

Are there any other query languages (or combinations of store+query language) I could use to query my store?

Thank you!
Re: [CDO] Backends and query languages [message #857473 is a reply to message #857347] Thu, 26 April 2012 15:10 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
If you use one of the db store adapters, you can use the sql backend's sql language, e.g. if you use mysql as your backend, then you can use (mysql specific) queries...
AFAIK, the DB store supports audits/branches...
icon3.gif  Re: [CDO] Backends and query languages [message #857478 is a reply to message #857473] Thu, 26 April 2012 15:16 Go to previous messageGo to next message
Guido Scalise is currently offline Guido ScaliseFriend
Messages: 16
Registered: April 2012
Junior Member
That's what I'm considering right now...
I found I need to (manually) add a cdo_revised=0 condition for every entity included in the query, in order to get the last version of the model. Am I right?

Also, a second question (that might need to go to a different thread)... Suppose I want to keep the audit views only for the last three months.. would it be right to delete any entities having cdo_revised <= (NOW() - 3 months) using plain SQL?

Thanks!!
Re: [CDO] Backends and query languages [message #857486 is a reply to message #857478] Thu, 26 April 2012 15:22 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 26.04.2012 17:16, schrieb Guido Scalise:
> That's what I'm considering right now...
> I found I need to (manually) add a cdo_revised=0 condition for every entity included in the query, in order to get the
> last version of the model. Am I right?
Yes, you're right. If branching is enabled, too, you need to add " AND cdo_branch=?".

Have a look at these methds for historical queries:

org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditClassMapping.initSQLStrings()
org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingClassMapping.initSQLStrings()

>
> Also, a second question (that might need to go to a different thread)... Suppose I want to keep the audit views only
> for the last three months.. would it be right to delete any entities having cdo_revised <= (NOW() - 3 months) using
> plain SQL?
That sounds as if it could work. I've never tried it, though.

Cheers
/Eike

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


Re: [CDO] Backends and query languages [message #858805 is a reply to message #857486] Fri, 27 April 2012 09:54 Go to previous messageGo to next message
Guido Scalise is currently offline Guido ScaliseFriend
Messages: 16
Registered: April 2012
Junior Member
Having the ability to change the DBStore to a different vendor poses an
interesting twist: if your SQL uses any nonstandard calls, your code
turns useless unless you somehow provide a method for the client to either:

a) identify the DBStore SQL flavour/dialect and use that data to "pick"
the correct SQL for a query.

b) create a method for the client to delegate the creation of a query to
a Handler able to create the "correct" SQL depending on the DBStore SQL
flavour. This could be done with a QueryHandler, and would also allow
the client queries to become completely decoupled of any DBStore/model
changes. This QueryHandler could either start from DBMS-agnostic SQL and
turn it into implementation-specific SQL or either have the queries
defined for each implementation.

I know it's possible with the correct queries to have the option "a",
but I really like the option "b", and I think it might be useful for
many CDO users.

What do you think about this?

Regards
/Guido


El 26/04/2012 17:22, Eike Stepper escribió:
> Am 26.04.2012 17:16, schrieb Guido Scalise:
>> That's what I'm considering right now...
>> I found I need to (manually) add a cdo_revised=0 condition for every
>> entity included in the query, in order to get the last version of the
>> model. Am I right?
> Yes, you're right. If branching is enabled, too, you need to add " AND
> cdo_branch=?".
>
> Have a look at these methds for historical queries:
>
> org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditClassMapping.initSQLStrings()
>
> org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingClassMapping.initSQLStrings()
>
>
>>
>> Also, a second question (that might need to go to a different
>> thread)... Suppose I want to keep the audit views only for the last
>> three months.. would it be right to delete any entities having
>> cdo_revised <= (NOW() - 3 months) using plain SQL?
> That sounds as if it could work. I've never tried it, though.
>
> Cheers
> /Eike
>
> ----
> http://www.esc-net.de
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
>
>
Re: [CDO] Backends and query languages [message #859003 is a reply to message #858805] Fri, 27 April 2012 12:02 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 27.04.2012 11:54, schrieb Guido Scalise:
> Having the ability to change the DBStore to a different vendor poses an interesting twist: if your SQL uses any
> nonstandard calls, your code turns useless unless you somehow provide a method for the client to either:
>
> a) identify the DBStore SQL flavour/dialect and use that data to "pick" the correct SQL for a query.
The store type is already accessible at the client side via CDOSession.getRepositoryInfo().getStoreType(). If you would
like to access more store-specific infos such as mapping strategy or DB adapter for the DBStore, please submit an
enhancement request.

> b) create a method for the client to delegate the creation of a query to a Handler able to create the "correct" SQL
> depending on the DBStore SQL flavour. This could be done with a QueryHandler, and would also allow the client queries
> to become completely decoupled of any DBStore/model changes. This QueryHandler could either start from DBMS-agnostic
> SQL and turn it into implementation-specific SQL or either have the queries defined for each implementation.
That's already possible. You can easily implement your own IQueryHandler and register it with the repository. Have a
look at the existing query handlers for examples.

>
> I know it's possible with the correct queries to have the option "a", but I really like the option "b", and I think it
> might be useful for many CDO users.
That's why it's possible today :P

Cheers
/Eike

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


>
> What do you think about this?
>
> Regards
> /Guido
>
>
> El 26/04/2012 17:22, Eike Stepper escribió:
>> Am 26.04.2012 17:16, schrieb Guido Scalise:
>>> That's what I'm considering right now...
>>> I found I need to (manually) add a cdo_revised=0 condition for every
>>> entity included in the query, in order to get the last version of the
>>> model. Am I right?
>> Yes, you're right. If branching is enabled, too, you need to add " AND
>> cdo_branch=?".
>>
>> Have a look at these methds for historical queries:
>>
>> org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditClassMapping.initSQLStrings()
>>
>> org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingClassMapping.initSQLStrings()
>>
>>
>>>
>>> Also, a second question (that might need to go to a different
>>> thread)... Suppose I want to keep the audit views only for the last
>>> three months.. would it be right to delete any entities having
>>> cdo_revised <= (NOW() - 3 months) using plain SQL?
>> That sounds as if it could work. I've never tried it, though.
>>
>> Cheers
>> /Eike
>>
>> ----
>> http://www.esc-net.de
>> http://thegordian.blogspot.com
>> http://twitter.com/eikestepper
>>
>>
>


Re: [CDO] Backends and query languages [message #879571 is a reply to message #857486] Thu, 31 May 2012 13:00 Go to previous messageGo to next message
Guido Scalise is currently offline Guido ScaliseFriend
Messages: 16
Registered: April 2012
Junior Member
Eike Stepper wrote on Thu, 26 April 2012 11:22
Am 26.04.2012 17:16, schrieb Guido Scalise:
> That's what I'm considering right now...
> I found I need to (manually) add a cdo_revised=0 condition for every entity included in the query, in order to get the
> last version of the model. Am I right?
Yes, you're right. If branching is enabled, too, you need to add " AND cdo_branch=?".


Would it make sense to add also cdo_version >= 0 so removed entities don't appear in the results?

[Updated on: Thu, 31 May 2012 13:01]

Report message to a moderator

Re: [CDO] Backends and query languages [message #879646 is a reply to message #879571] Thu, 31 May 2012 15:18 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 31.05.2012 15:00, schrieb Guido Scalise:
> Eike Stepper wrote on Thu, 26 April 2012 11:22
>> Am 26.04.2012 17:16, schrieb Guido Scalise:
>> > That's what I'm considering right now...
>> > I found I need to (manually) add a cdo_revised=0 condition for every entity included in the query, in order to get
>> the > last version of the model. Am I right?
>> Yes, you're right. If branching is enabled, too, you need to add " AND cdo_branch=?".
>
>
> Would it make sense to add also cdo_version >= 0 so removed entities don't appear?
I have currently no access to the code, but doesn't cdo_version < 0 imply cdo_revised != 0?

Cheers
/Eike

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


Re: [CDO] Backends and query languages [message #880039 is a reply to message #879646] Fri, 01 June 2012 10:19 Go to previous messageGo to next message
Guido Scalise is currently offline Guido ScaliseFriend
Messages: 16
Registered: April 2012
Junior Member
Eike Stepper wrote on Thu, 31 May 2012 11:18

I have currently no access to the code, but doesn't cdo_version < 0 imply cdo_revised != 0?


What should happen if the last action on a given object was a deletion?
I can confirm we are seeing objects with cdo_version < 0 and cdo_revised = 0

Regards,
Guido
Re: [CDO] Backends and query languages [message #880064 is a reply to message #880039] Fri, 01 June 2012 10:53 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 01.06.2012 12:19, schrieb Guido Scalise:
> Eike Stepper wrote on Thu, 31 May 2012 11:18
>> I have currently no access to the code, but doesn't cdo_version < 0 imply cdo_revised != 0?
>
>
> What should happen if the last action on a given object was a deletion?
> I can confirm we are seeing objects with cdo_version < 0 and cdo_revised = 0
Hmm, I vaguely remember that the introduction of branching and merging has made this necessary. Probably best to just
ignore my previous post :P

Cheers
/Eike

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


Previous Topic:EMF Framework Validation
Next Topic:[CDO] Server/Clone Architecture advise needed
Goto Forum:
  


Current Time: Fri Apr 26 21:04:56 GMT 2024

Powered by FUDForum. Page generated in 0.05602 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top