You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Angus Berry <an...@elken.com> on 2004/03/25 23:00:18 UTC

OQL Query by date

(rc5)
>>From everything I've read I think this should work. I'm trying to select
an object by it's id & date:

query.create("select invoice from " + InvoiceBO.class.getName() + "
where invoiceID = $1 and date = $2");

Before I even get to bind the query values (query.bind(invNum)), I get
an error saying:
line 1: unexpected token: and

The following select also fails:
query.create("select invoice from " + InvoiceBO.class.getName() + "
where date = $1");
line 1: unexpected token: date

However, if I use a line like the one below it will select OK (given the
correct params):
query.create("select invoice from " + InvoiceBO.class.getName() + "
where invoiceID = $1 and clientName = $2");

Have done a bad thing by have a property called 'date' in my class, or
is my syntax incorrect for a date select.

thanks



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: OQL Query by date

Posted by Angus Berry <an...@elken.com>.
No blame... it would be nice if in OQL you could do something like:

query.create("select myObject from " + myClass.class.getName() + " where
[date] = $1");

..but adding the square brackets I'm just asking for a deviation from
OQL and making it more like SQL, instead of refactoring my code :-)

On Fri, 2004-03-26 at 10:00, Brian McCallister wrote:
> On Mar 26, 2004, at 9:15 AM, Angus Berry wrote:
> 
> > Thanks... for the record then 'date' was a bad name for a class
> > attribute to be persisted in OQL?
> >
> 
> Yes, unfortunately. Blame ODMG though, not us please ;-)
> 
> -Brian
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> a


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: OQL Query by date

Posted by Brian McCallister <mc...@forthillcompany.com>.
On Mar 26, 2004, at 9:15 AM, Angus Berry wrote:

> Thanks... for the record then 'date' was a bad name for a class
> attribute to be persisted in OQL?
>

Yes, unfortunately. Blame ODMG though, not us please ;-)

-Brian



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: OQL Query by date

Posted by Angus Berry <an...@elken.com>.
Thanks... for the record then 'date' was a bad name for a class
attribute to be persisted in OQL?

On Fri, 2004-03-26 at 09:20, Brian McCallister wrote:
> Here is the problem:
> 
> from src/java/org/apache/ojb/odmg/oql/OQLLexerTokenTypes.txt
> 
> LITERAL_date="date"=61
> 
> the word "date" is a token in OQL =(
> 
> -Brian
> 
> On Mar 25, 2004, at 5:00 PM, Angus Berry wrote:
> 
> > (rc5)
> >> From everything I've read I think this should work. I'm trying to 
> >> select
> > an object by it's id & date:
> >
> > query.create("select invoice from " + InvoiceBO.class.getName() + "
> > where invoiceID = $1 and date = $2");
> >
> > Before I even get to bind the query values (query.bind(invNum)), I get
> > an error saying:
> > line 1: unexpected token: and
> >
> > The following select also fails:
> > query.create("select invoice from " + InvoiceBO.class.getName() + "
> > where date = $1");
> > line 1: unexpected token: date
> >
> > However, if I use a line like the one below it will select OK (given 
> > the
> > correct params):
> > query.create("select invoice from " + InvoiceBO.class.getName() + "
> > where invoiceID = $1 and clientName = $2");
> >
> > Have done a bad thing by have a property called 'date' in my class, or
> > is my syntax incorrect for a date select.
> >
> > thanks
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> >
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> C


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: OQL Query by date

Posted by Brian McCallister <mc...@forthillcompany.com>.
Here is the problem:

from src/java/org/apache/ojb/odmg/oql/OQLLexerTokenTypes.txt

LITERAL_date="date"=61

the word "date" is a token in OQL =(

-Brian

On Mar 25, 2004, at 5:00 PM, Angus Berry wrote:

> (rc5)
>> From everything I've read I think this should work. I'm trying to 
>> select
> an object by it's id & date:
>
> query.create("select invoice from " + InvoiceBO.class.getName() + "
> where invoiceID = $1 and date = $2");
>
> Before I even get to bind the query values (query.bind(invNum)), I get
> an error saying:
> line 1: unexpected token: and
>
> The following select also fails:
> query.create("select invoice from " + InvoiceBO.class.getName() + "
> where date = $1");
> line 1: unexpected token: date
>
> However, if I use a line like the one below it will select OK (given 
> the
> correct params):
> query.create("select invoice from " + InvoiceBO.class.getName() + "
> where invoiceID = $1 and clientName = $2");
>
> Have done a bad thing by have a property called 'date' in my class, or
> is my syntax incorrect for a date select.
>
> thanks
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org