Re: [OJB-developers] OJB DISTINCT
Brought to you by:
thma
From: Jakob B. <jbr...@ho...> - 2001-12-10 16:42:37
|
hi dirk, there's a setDistinct(boolean) in QueryByCriteria. The third attribute is only for convenience. jakob ----- Original Message ----- From: "Dirk Olmes" <di...@xa...> To: "Jakob Braeuchi" <jbr...@ho...> Cc: "Objectbridge Developers List (E-mail)" <obj...@li...> Sent: Monday, December 10, 2001 12:56 PM Subject: Re: [OJB-developers] OJB DISTINCT > > the attached zip enables setting DISTINCT in sql-queries. > > there are new constructors in QueryFactory with an additional boolean > > parameter 'distinct'. > > > > the following snippet shows a sample (one person has many accounts and > > many > > telephones) and the generated sql. > > the sql also shows, that multiple joins work: > > > > Query query; > > Criteria crit; > > > > System.out.println("\nread all person with konti.saldo > 200 and tel > > like > > 031%"); > > crit = new Criteria(); > > crit.addGreaterThan("konti.saldo",new Integer(100)); > > crit.addLike("telefone.nummer","031%"); > > query = new QueryByCriteria(Person.class, crit,true); // true -> > > DISTINCT > > Not knowing much of the internals of OJB (I dug into the source once but > this is long time gone) I find the third argument to the constructor > awkward API. > > Wouldn't it be clearer API to be able to write: > > crit = new Criteria(); > crit.addGreaterThan("konti.saldo",new Integer(100)); > crit.addLike("telefone.nummer","031%");4 > crit.setUsesDistinct(true); > query = new QueryByCriteria(Person.class, crit); > > Just my thoughts, > > -dirk > > |