db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pfiester, Jan" <jan.pfies...@ict.fraunhofer.de>
Subject AW: Problems to set up a subquery
Date Fri, 20 Oct 2006 09:03:32 GMT
Hello Thomas,
I totally agree with you, but still i'm not able to come up with a solution i would call a
good one.
Can you please tell me what i'm doing wrong in the code below:

My current working solution but not considered as a good one:
	Criteria criteria = new Criteria();
	criteria.add(	
		KundenadressePeer.KUNDENADRESS_ID, 
		(Object)"kundenadresse.KUNDENADRESS_ID NOT IN (SELECT adressenreferenz.KUNDENADRESS_ID 
				FROM adressenreferenz)", 
		Criteria.CUSTOM
	);
		
Sort of a "clean" approach, but not working due sql exections:
	Criteria subCriteria = new Criteria();
	subCriteria.add(AdressenreferenzPeer.KUNDENADRESS_ID, Criteria.ALL);
		
	Criteria criteria = new Criteria();
	criteria.add(KundenadressePeer.KUNDEN_ID, kundeId, Criteria.EQUAL);
	criteria.addNotIn(KundenadressePeer.KUNDENADRESS_ID, AdressenreferenzPeer.doSelect(subCriteria));

	return KundenadressePeer.doSelect(criteria);

Many thx in Advance,
Jan





 

-----Urspr√ľngliche Nachricht-----
Von: Thomas Vandahl [mailto:tv@apache.org] 
Gesendet: Donnerstag, 19. Oktober 2006 17:52
An: Apache Torque Users List
Betreff: Re: Problems to set up a subquery

Thomas Fischer wrote:
> Hm, writing SQL is one of the the things that Torque wants to avoid. 
> One of the reasons for this is portability between databases. Though 
> Torque is certainly not perfectly portable, it is much better than plain SQL.
[...]
> So in my eyes, one should think twice before using custom SQL. There 
> are cases where it cannot be avoided (see below), but I would think 
> twice before using it.

I second that. It is sometimes surprising what *can* be done with the Torque Criteria. Custom
SQL breaks the basic idea of Torque.

Bye, Thomas.

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

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


Mime
View raw message