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 Guido Beutler <gu...@hrs.de> on 2004/03/25 17:09:44 UTC
Mapping two classes two one table
Hi,
I've got a small problem.
I have a table with many columns. I would like to select only the
primary key field with a complex select first.
It's like a candidate list. From that I can find the correct value
(independen from the database).
For the correct value I would like to receive all data.
I build two classes and mapped them to the same table. This is working
fine. I got one class
only with the primary key and another with all fields. I do not use
inheritance, because all
entries of the table have the same type (there is no third class with
another type).
The problem now is , that during the select for the primary key class
OJB creates a select
for all colums although only the primary key is needed. This is working,
the primary key
class is filled correctly. The the reason for building a primary key
class was the performance impact
of reading all coloumns. I would like to avoid reading all colums if I
need only one.
Is there a way to avoid reading all coulums directly?
best regards,
Guido
---------------------------------------------------------------------
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
OQL Query by date
Posted by Angus Berry <an...@elken.com>.
(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: Mapping two classes two one table
Posted by Edson Carlos Ericksson Richter <ed...@mgrinformatica.com.br>.
The result of a report query is a Object [], where each element
represents a row from the database, and is a Object[] (one value for
each field returned).
Best regards,
Edson Richter
Guido Beutler wrote:
> Hi jakob,
>
> Thanks for the fast reply!
> works fine but one shot question: How do I get the values (colums)
> from the object ?
> At the test cases I found only asserts on the size of the collection.
> Of course I would like to get the values.
> Thanks in Advance!!
>
> best regards,
>
> Guido
>
> Jakob Braeuchi wrote:
>
>> hi guido,
>>
>> use a report-query to retrieve the pks only.
>>
>> hth
>> jakob
>>
>> Guido Beutler wrote:
>>
>>> Hi,
>>>
>>> I've got a small problem.
>>> I have a table with many columns. I would like to select only the
>>> primary key field with a complex select first.
>>> It's like a candidate list. From that I can find the correct value
>>> (independen from the database).
>>> For the correct value I would like to receive all data.
>>> I build two classes and mapped them to the same table. This is
>>> working fine. I got one class
>>> only with the primary key and another with all fields. I do not use
>>> inheritance, because all
>>> entries of the table have the same type (there is no third class
>>> with another type).
>>>
>>> The problem now is , that during the select for the primary key
>>> class OJB creates a select
>>> for all colums although only the primary key is needed. This is
>>> working, the primary key
>>> class is filled correctly. The the reason for building a primary key
>>> class was the performance impact
>>> of reading all coloumns. I would like to avoid reading all colums if
>>> I need only one.
>>> Is there a way to avoid reading all coulums directly?
>>>
>>> best regards,
>>>
>>> Guido
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>
>
> ---------------------------------------------------------------------
> 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
Re: Mapping two classes two one table
Posted by Guido Beutler <gu...@hrs.de>.
Hi jakob,
Thanks for the fast reply!
works fine but one shot question: How do I get the values (colums) from
the object ?
At the test cases I found only asserts on the size of the collection. Of
course I would like to get the values.
Thanks in Advance!!
best regards,
Guido
Jakob Braeuchi wrote:
> hi guido,
>
> use a report-query to retrieve the pks only.
>
> hth
> jakob
>
> Guido Beutler wrote:
>
>> Hi,
>>
>> I've got a small problem.
>> I have a table with many columns. I would like to select only the
>> primary key field with a complex select first.
>> It's like a candidate list. From that I can find the correct value
>> (independen from the database).
>> For the correct value I would like to receive all data.
>> I build two classes and mapped them to the same table. This is
>> working fine. I got one class
>> only with the primary key and another with all fields. I do not use
>> inheritance, because all
>> entries of the table have the same type (there is no third class with
>> another type).
>>
>> The problem now is , that during the select for the primary key class
>> OJB creates a select
>> for all colums although only the primary key is needed. This is
>> working, the primary key
>> class is filled correctly. The the reason for building a primary key
>> class was the performance impact
>> of reading all coloumns. I would like to avoid reading all colums if
>> I need only one.
>> Is there a way to avoid reading all coulums directly?
>>
>> best regards,
>>
>> Guido
>>
>> ---------------------------------------------------------------------
>> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Mapping two classes two one table
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi guido,
use a report-query to retrieve the pks only.
hth
jakob
Guido Beutler wrote:
> Hi,
>
> I've got a small problem.
> I have a table with many columns. I would like to select only the
> primary key field with a complex select first.
> It's like a candidate list. From that I can find the correct value
> (independen from the database).
> For the correct value I would like to receive all data.
> I build two classes and mapped them to the same table. This is working
> fine. I got one class
> only with the primary key and another with all fields. I do not use
> inheritance, because all
> entries of the table have the same type (there is no third class with
> another type).
>
> The problem now is , that during the select for the primary key class
> OJB creates a select
> for all colums although only the primary key is needed. This is working,
> the primary key
> class is filled correctly. The the reason for building a primary key
> class was the performance impact
> of reading all coloumns. I would like to avoid reading all colums if I
> need only one.
> Is there a way to avoid reading all coulums directly?
>
> best regards,
>
> Guido
>
> ---------------------------------------------------------------------
> 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