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 "T. K. Chris" <ch...@yahoo.fr> on 2004/11/07 19:36:09 UTC

sql Join request with QueryBySQL

Hi, 
Pb. I have 2 tables : CLIENTS, UTILISATEURS mapped by
java classes ClientsVO and UtilisateursVO; there is no
relation defined between the both tables. The
sqlString below is the sql request needed to retrieve
the data.

My problem is that I did not find any example showing
how to trigger raw SQL requests. I need some
references, examples or tutorials of how to do this.
Please could you tell me what is wrong with this. 
String sqlString = "SELECT CLIENTS.CL_ID,
CLIENTS.CL_NOM, CLIENTS.CL_PRENOM, CLIENTS.CL_ADRESSE,
CLIENTS.CL_CP, CLIENTS.CL_VILLE, CLIENTS.CL_PAYS,
CLIENTS.CL_TEL"
+ "FROM UTILISATEURS"
+ "LEFT OUTER JOIN CLIENTS"
+ "ON UTILISATEURS.UT_ID=CLIENTS.CL_ID"
+ "ON UTILISATEURS.UT_ID=CLIENTS.CL_ID"
+ "WHERE UT_VIS="+sVin;
QueryBySQL queryBySql = new
QueryBySQL(ClientsVO.class, sqlString);
Collection clients =
broker.getCollectionByQuery(queryBySql); 
In general, what is the syntax of triggering raw sql
JOIN request with OJB using independant table (i.e.
without any relationship between tables except common
primary key comumn.) 
Thanks.



	

	
		
Vous manquez d’espace pour stocker vos mails ? 
Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour dialoguer instantanément avec vos amis. A télécharger gratuitement sur http://fr.messenger.yahoo.com

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


Re: sql Join request with QueryBySQL

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi t.k.,

when you use query-by-sql it's important to list all attributes of the desired 
class in the select-clause.

if you need only a subset of the attributes you can use a reportquery-by-sql.

hth
jakob

T. K. Chris schrieb:

> Hi, 
> Pb. I have 2 tables : CLIENTS, UTILISATEURS mapped by
> java classes ClientsVO and UtilisateursVO; there is no
> relation defined between the both tables. The
> sqlString below is the sql request needed to retrieve
> the data.
> 
> My problem is that I did not find any example showing
> how to trigger raw SQL requests. I need some
> references, examples or tutorials of how to do this.
> Please could you tell me what is wrong with this. 
> String sqlString = "SELECT CLIENTS.CL_ID,
> CLIENTS.CL_NOM, CLIENTS.CL_PRENOM, CLIENTS.CL_ADRESSE,
> CLIENTS.CL_CP, CLIENTS.CL_VILLE, CLIENTS.CL_PAYS,
> CLIENTS.CL_TEL"
> + "FROM UTILISATEURS"
> + "LEFT OUTER JOIN CLIENTS"
> + "ON UTILISATEURS.UT_ID=CLIENTS.CL_ID"
> + "ON UTILISATEURS.UT_ID=CLIENTS.CL_ID"
> + "WHERE UT_VIS="+sVin;
> QueryBySQL queryBySql = new
> QueryBySQL(ClientsVO.class, sqlString);
> Collection clients =
> broker.getCollectionByQuery(queryBySql); 
> In general, what is the syntax of triggering raw sql
> JOIN request with OJB using independant table (i.e.
> without any relationship between tables except common
> primary key comumn.) 
> Thanks.
> 
> 
> 
> 	
> 
> 	
> 		
> Vous manquez d’espace pour stocker vos mails ? 
> Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
> Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/
> 
> Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour dialoguer instantanément avec vos amis. A télécharger gratuitement sur http://fr.messenger.yahoo.com
> 
> ---------------------------------------------------------------------
> 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