you are right it's not in rc3, but only in latest CVS head.
Shane Mingins wrote:
Hi Thomas
I was browsing through OQLTest and could not see testInListQuery(). The source I have is db-ojb-1.0.rc3-src.tgz.
Am I missing some source?
Cheers Shane
-----Original Message-----
From: Thomas Mahler [mailto:[EMAIL PROTECTED] Sent: Saturday, 28 June 2003 6:19 a.m.
To: OJB Users List
Subject: Re: AW: OQL Query
Hi Julia,
he is a sample from the testcase OqlTest from our ODMG testsuite: public void testInListQuery() throws Exception { //objects that are part of a 1:n relation, i.e. they have fk-fields Mammal elephant = new Mammal(4, "Minnie", 4); Mammal cat = new Mammal(4, "Winston", 4); Reptile snake = new Reptile(4, "Skuzzlebutt", "green"); Implementation odmg = OJB.getInstance();
Database db = odmg.newDatabase(); db.open(databaseName, Database.OPEN_READ_WRITE); Transaction tx = odmg.newTransaction(); tx.begin(); db.makePersistent(elephant); db.makePersistent(cat); db.makePersistent(snake); tx.commit();
tx = odmg.newTransaction(); tx.begin(); OQLQuery query = odmg.newOQLQuery(); query.create("select animals from " + InterfaceAnimal.class.getName() + " where name in list (\"Minnie\", \"Winston\", \"Skuzzlebutt\")"); List animals = (List) query.execute(); tx.commit(); assertEquals(3, animals.size()); }
you'll find tons of useful example in the testcases, so it's really worth browsing.
cheers, Thomas
[EMAIL PROTECTED] wrote:
Hi again,
sorry for bothering you again.
Hmm, it works fine for me...
But maybe you could give a source code example on how you use string comparison in the where clause of an oql query ..
thanks in advance julia.
-----Urspr�ngliche Nachricht----- Von: Mahler Thomas [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 27. Juni 2003 15:39 An: 'OJB Users List' Betreff: RE: OQL Query
Hi again,
Hi Thomas,
I tried it out with several several quotes. The DEBUG Level for the SqlGenerator doesn't say anything.
Hmm, it works fine for me... So just try to use P6Spy.
Isn't there a documentation for the OQL implementated in OJB? Because it it
is not standard conform! Otherwise some other things like
"select allObject from ServerVOExtent as allObjects" would work, etc. So
from where should I know what is supported and how the syntax is?
good point. Unfortunately the only exact documentation is the oql grammar that is used to generate parser. It can be read as a simple EBNF Grammar, so it should get you started.
http://cvs.apache.org/viewcvs.cgi/*checkout*/db-ojb/src/java/org/apache/ojb/
odmg/oql/oql-ojb.g?rev=HEAD&content-type=text/plain
The really sad story about this grammar is, that it was taken from the official ODMG website and only modified to generate OJB queries. We did
not
modify the structure of the grammar itself.
cheers, Thomas
Julia.
-----Urspr�ngliche Nachricht----- Von: Mahler Thomas [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 27. Juni 2003 15:18 An: 'OJB Users List' Betreff: RE: OQL Query
Hi Julia,
I think it has to do with the extra quotes.
You should have a look at the generated SQL statements (either by enabling
log level DEBUG for SqlGenerator or by using the P6Spy tracer (as documented
in the FAQ))
another option would be to use oql parameter binding.
cheers, Thomas
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, June 27, 2003 2:28 PM
To: [EMAIL PROTECTED]
Subject: OQL Query
Hello,
I have a Value Object called ServerVO with a corresponding table. The table
contains two entries. The primary key is composed of the fields:
protected String locale;
protected int entryId;
It is no problem to select all entries contained in the
table with the
following query: query.create("select allObjects from " + ServerVO.class.getName());
It is also no problem to select by a specific id:
query.create("select allObjects from " + ServerVO.class.getName() + " where
entryId=" + primaryKey);
But I'm not able to select by the locale:
query.create("select allObjects from " + ServerVO.class.getName() + " where
locale = \"EN\"");
I dont get a exception or something like this. It simply returns no result.
I checked the spelling of the columns and attributs over and over again. And
i swear that the entries in the database exist and that locale is "EN"! ;-)
So what else could be wrong?
Where can I find an OQL reference instead (because the odmg site is down).
Julia.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
