Re: Simple query

Armin Waibel <[email protected]>
Newsgroups gmane.comp.jakarta.ojb.user
Message-ID <[email protected]>
Hi Andrei,

Andrei Harangus wrote:
> Having the following class:
>  
>  
> class Clazz {
> private String field1;
> private String field2;
> }
>  
> Mapped to 
>  
> table tbl1(field1, field2)
>  
> What is the code snippet that would generate the sql
> select * from tbl1 where field1 = field2
>  

Criteria crit = new Criteria().addEqualToField("field1", "field2"); ***
QueryByCriteria q = QueryFactory.newQuery(Clazz.class, crit);
q.setDistinct(true);
Collection result = broker.getCollectionByQuery(q);

(***) it's based on latest version from SVN (OJB_1_0_RELEASE branch), 
maybe you have use crit.addEqualToField("field1", "field2").

regards,
Armin

> Regards,
> Andrei
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.