Apache JDO Project - IN operator missed?

This is Interesting: Free IT Magazines  
Home > Archive > Apache JDO Project > November 2006 > IN operator missed?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author IN operator missed?
Luca Garulli

2006-11-13, 1:11 pm

Hi,
Working in real-world applications using JDO 2.0 I beware about the SQL IN
equivalend operator missed by spec. An example:

public class Questionnaire{
...
private Employee employee;
...
}

I'd like to get any Questionnaire instances for the following employee:
Luca, Robert and Chris. The CONTAINS operator works only on collection, but
it could be useful to execute a query like this:

List<Employee> list= new ArrayList<Employee>();
// LET'S THINK E1-E2-E3 are loaded before
List.add( e1 );
List.add( e2 );
List.add( e3 );

Query query = iManager.newQuery();
query.setClass( Questionnaire.class );
query.setFilter( "list.contains( employee )" );
query.declareVariables( "java.util.Collection list" );
query.execute( list );

JDO implementation should translate the query by using SQL IN operator and
the OID of Employee objects contained in the LIST collection passed as
parameter.

What do you think?

Bye,
Luca Garulli
CTO of Asset Data srl
www.RomaFramework.org


Michael Bouschen

2006-11-13, 1:11 pm

Hi Luca,

the JDOQL query you specified below should work as it is today. As you
said the contains operator expects a collection on the left. This
collection may be a collection parameter and does not need to be a
collection field.

Regards Michael

> Hi,
> Working in real-world applications using JDO 2.0 I beware about the SQL IN
> equivalend operator missed by spec. An example:
>
> public class Questionnaire{
> ...
> private Employee employee;
> ...
> }
>
> I'd like to get any Questionnaire instances for the following employee:
> Luca, Robert and Chris. The CONTAINS operator works only on collection, but
> it could be useful to execute a query like this:
>
> List<Employee> list= new ArrayList<Employee>();
> // LET'S THINK E1-E2-E3 are loaded before
> List.add( e1 );
> List.add( e2 );
> List.add( e3 );
>
> Query query = iManager.newQuery();
> query.setClass( Questionnaire.class );
> query.setFilter( "list.contains( employee )" );
> query.declareVariables( "java.util.Collection list" );
> query.execute( list );
>
> JDO implementation should translate the query by using SQL IN operator and
> the OID of Employee objects contained in the LIST collection passed as
> parameter.
>
> What do you think?
>
> Bye,
> Luca Garulli
> CTO of Asset Data srl
> www.RomaFramework.org
>



--
Michael Bouschen Tech@Spree Engineering GmbH
mailto:mbo.tech@spree.de http://www.tech.spree.de/
Tel.:++49/30/235 520-33 Buelowstr. 66
Fax.:++49/30/2175 2012 D-10783 Berlin


Craig L Russell

2006-11-13, 1:11 pm

Michael Bouschen

2006-11-13, 1:11 pm

Hi Luca,

Craig is right, I overlooked you tried to declare list as a variable. So
the query works if you declare list as a parameter, so calling
query.declareParameters("java.util.Collection list" ) instead of
query.declareVariables.

Regards Michael
> Hi Luca,
>
> the JDOQL query you specified below should work as it is today. As you
> said the contains operator expects a collection on the left. This
> collection may be a collection parameter and does not need to be a
> collection field.
>
> Regards Michael
>
>
>



--
Michael Bouschen Tech@Spree Engineering GmbH
mailto:mbo.tech@spree.de http://www.tech.spree.de/
Tel.:++49/30/235 520-33 Buelowstr. 66
Fax.:++49/30/2175 2012 D-10783 Berlin


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com