You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Rene Scheibe <re...@tngtech.com> on 2010/07/26 17:30:45 UTC

Howto implement SQL EXIST subquery with EntityConditions

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At the moment we remove some entities using a hand-crafted SQL statement
which is quite ugly. Unfortunately we don't know any other solution.

Here is the code snippet so far:


String sql =
  "EXISTS (SELECT p.product_id"
+ "          FROM prodcut p"
+ "         WHERE p.product_id = product_category_member.product_id"
+ "           AND p.primary_product_category_id <>
product_category_member.product_category_id"
+ "           AND p.facility_id = '" + facilityId + "'"
+ ")";

EntityCondition condition = EntityCondition.makeConditionWhere(sql);
delegator.removeByCondition("ProductCategoryMember", condition);


How is it possible to refactor this using EntityConditions?

Regards,
René
- -- 
René Scheibe * rene.scheibe@tngtech.com * +49-176-62192936
TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterföhring
Geschäftsführer: Henrik Klagges, Gerhard Müller, Christoph Stock
Sitz: Unterföhring * Amtsgericht München * HRB 135082
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxNqiUACgkQUXs9EHvIuCrXYQCfWCAz2+FyL5/pT1xxySimT2og
nOYAnjRh4990AYLkqv+S2B2SzGJBzWaM
=XT8J
-----END PGP SIGNATURE-----