db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Αντώνης Λεμπέσης <ant...@di.uoa.gr>
Subject Re: J1.6/Torque: avoiding the return of multiples (the same database entry, several times) with 'setDistinct()']
Date Mon, 25 Jul 2005 13:21:02 GMT
I think I was half asleep when I wrote these... The following code 
should work:

    int iCategoryId = Integer.parseInt(categoryId);
    Criteria prodcrit = new Criteria();

    prodcrit.add(ProductInCategoryPeer.PROD_ID, 0, Criteria.GREATER_THAN);
    if (iCategoryId != 0)  {
         prodcrit.add(ProductInCategoryPeer.CAT_ID, iCategoryId);
    }
    prodcrit.addJoin(ProductInCategoryPeer.PROD_ID, ProductPeer.ID);
    prodcrit.addJoin(ProductInCategoryPeer.CAT_ID, CategoryPeer.ID);

    prodcrit.addAscendingOrderByColumn(ProductPeer.PRODUCT_NAME);
    prodcrit.setDistict();

    return ProductPeer.doSelect(prodcrit);

Good luck and sorry for the previous mistake,
Antonis

antleb@di.uoa.gr wrote:

>Sven Richter <srman@gmx.net> wrote:
>
>...
>  
>
>>        if (iCategoryId != 0)
>>
>>        {
>>
>>            prodcrit.add(ProductInCategoryPeer.CAT_ID, iCategoryId);
>>    
>>
>
>the method you need is "addJoin" and not "add".
>
>  
>
>>        }
>>
>>        prodcrit.addAscendingOrderByColumn(ProductPeer.PRODUCT_NAME);
>>
>>        prodcrit.setDistinct();
>>
>>    
>>
>
>...
>
>  
>
>>Thanks a lot,
>>Sven.
>>
>>    
>>
>
>Good luck,
> Antonis
>
>
>---------------------------------------------------------------------
>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