Re: QueryBySQL for ojb rc4

2003-08-29 Thread Thomas Mahler
Hi,

AFAIK the documentation on OJB queries (query.html) mentions that:
1. if you use getObjectByQuery, getCollectionByQuery or 
getIteratorByQuery OJB materializes complete instances of your 
persistant class. Thus a SQL query must contain all fields defined in 
the repository.

2. if you want to use arbitrary Select statements, that do not contain 
all fields of a class, you have to use ReportQueries.

cheers,
Thomas
Sng Wee Jim wrote:
Hi,

Thanks Roland.
I managed to get what is needed (ie. only selected columns) by
  QueryBySQL query1 = QueryFactory.newQuery(java.lang.Class, sql) ;
  Iterator itr = broker.getReportQueryIteratorByQuery(query1);
maybe the FAQ section that mentions QueryBySQL should be updated to mention this.

- Jim





Roland Carlsson wrote:

I just did a QueryBySQL and after a little work I got to the following
conclusion.


All non-primary-key fields MUST be returned by the query. Primay-key fields
may be returned but it not a requirerment.


I guess that it is a design-choice to force the developer to use as complete
objects as possible. You should not get objects where most fields are null
unless they are that in the database.
Regards
Roland Carlsson
-
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]


Re: QueryBySQL for ojb rc4

2003-08-29 Thread Sng Wee Jim
Hi,

Thanks Roland.
I managed to get what is needed (ie. only selected columns) by
  QueryBySQL query1 = QueryFactory.newQuery(java.lang.Class, sql) ;
  Iterator itr = broker.getReportQueryIteratorByQuery(query1);

maybe the FAQ section that mentions QueryBySQL should be updated to mention this.

- Jim






Roland Carlsson wrote:
>I just did a QueryBySQL and after a little work I got to the following
conclusion.

>All non-primary-key fields MUST be returned by the query. Primay-key fields
may be returned but it not a requirerment.

>I guess that it is a design-choice to force the developer to use as complete
objects as possible. You should not get objects where most fields are null
unless they are that in the database.

Regards
Roland Carlsson

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: QueryBySQL for ojb rc4

2003-08-28 Thread Roland Carlsson
Hi!
I just did a QueryBySQL and after a little work I got to the following
conclusion.

All non-primary-key fields MUST be returned by the query. Primay-key fields
may be returned but it not a requirerment.

I guess that it is a design-choice to force the developer to use as complete
objects as possible. You should not get objects where most fields are null
unless they are that in the database.

Regards
Roland Carlsson


- Original Message - 
From: "Sng Wee Jim" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 28, 2003 5:37 PM
Subject: QueryBySQL for ojb rc4


> > Hi,
> >
> > Anyone encountered problem with using the query type: QueryBySQL?
> >
> > I am doing something like
> >   QueryBySQL query1 = QueryFactory.newQuery(java.lang.Class, sql) ;
> >   Iterator itr = broker.getIteratorByQuery(query1);
> >
> > however the while iterating through the resultset, the object returned
> > by the iterator are all null.
> >
> > I tried the same query with
> >  Collection clt = broker.getCollectionByQuery(query1);
> > but the size of the return collection is zero.
> >
> > The resultset of the SQL is not empty. (I ran the SQL in MySQL).
> > Is it a bug, or do I need to set some properties?
> >
>
>
>
> -
> 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]



Re: QueryBySQL for ojb rc4

2003-08-28 Thread Roland Carlsson
Hi!
You sql-query must return ALL non-primary-key fields as defined in the
repository. If it is a bug or design-choice i don't know although I can
guess that it is a design-choice to keep objects complete as far as
posible Anyone knows??

Example:

 
  
 


Your sql must return anInteger and aString... it is not necesery that it
returns id. I guess that it can't demand the primary key if group-functions
is used.

- Original Message - 
From: "Sng Wee Jim" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 28, 2003 5:37 PM
Subject: QueryBySQL for ojb rc4


> > Hi,
> >
> > Anyone encountered problem with using the query type: QueryBySQL?
> >
> > I am doing something like
> >   QueryBySQL query1 = QueryFactory.newQuery(java.lang.Class, sql) ;
> >   Iterator itr = broker.getIteratorByQuery(query1);
> >
> > however the while iterating through the resultset, the object returned
> > by the iterator are all null.
> >
> > I tried the same query with
> >  Collection clt = broker.getCollectionByQuery(query1);
> > but the size of the return collection is zero.
> >
> > The resultset of the SQL is not empty. (I ran the SQL in MySQL).
> > Is it a bug, or do I need to set some properties?
> >
>
>
>
> -
> 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]



QueryBySQL for ojb rc4

2003-08-28 Thread Sng Wee Jim
Hi,

Anyone encountered problem with using the query type: QueryBySQL?

I am doing something like
  QueryBySQL query1 = QueryFactory.newQuery(java.lang.Class, sql) ;
  Iterator itr = broker.getIteratorByQuery(query1);
however the while iterating through the resultset, the object returned 
by the iterator are all null.

I tried the same query with
 Collection clt = broker.getCollectionByQuery(query1);
but the size of the return collection is zero.
The resultset of the SQL is not empty. (I ran the SQL in MySQL).
Is it a bug, or do I need to set some properties?


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]