Thomas,

Does this erros means in the QueryBySQL I have to use column number
instead of column name for the order by clause. Or I have to do some
other configuration. Please help, because I used quite a lot QueryBySql
in my project. 

Thanks

Stephen

> -----Original Message-----
> From: Stephen Ting [mailto:[EMAIL PROTECTED]] 
> Sent: 23 December 2002 11:26
> To: 'Ojb Users List'
> Subject: Some error in ORDER BY clause
> 
> 
>  
> I upgrade to OJB 0.9.8 recently and found the following error 
> in ORDER BY clause appear. Before upgrade, it's run without 
> any problems in version 0.9.5. 
>  
> Could anyone tell me what's the problems?
>  
> [org.apache.ojb.broker.accesslayer.JdbcAccess] ERROR: 
> SQLException during the execution of the SQL query: Column 
> name brand.brand_make is invalid in the ORDER BY clause 
> because it is not contained in an aggregate function and 
> there is no GROUP BY clause. Column name 'brand.brand_make' 
> is invalid in the ORDER BY clause because it is not contained 
> in an aggregate function and there is no GROUP BY clause.
> 
>  
>         String sql = "SELECT brand_make FROM brand ORDER BY brand_make
> ASC";                              
>         ******* if i change the above sql to the below one, 
> this error will disappear.
>          String sql = "SELECT brand_make FROM brand ORDER BY 1 ASC";
> 
>  
>         Query query = QueryFactory.newQuery(BrandBO.class, sql);  
>  
>         Collection object = null;
>         PersistenceBroker broker = null;
>         try{
>             //throw PBFactoryException
>             broker = PersistenceBrokerFactory.createPersistenceBroker(
>                     new PBKey("repository.xml" , null, null));
>             
>             object = broker.getCollectionByQuery(query); 
> //throw persistencebrokerexception
>             //return back cascade retrieval to original state
>             
>         }catch(PBFactoryException e){
>             if(broker != null) broker.close();            
>             throw new DatastoreException("Fail to connect to the
> Database" + e.getMessage());             
>         }
>         catch(PersistenceBrokerException e){
>             if(broker != null) broker.close();            
>             throw new DatastoreException("Fail to get the 
> invoice from "
> + site.getName());            
>         }
>         finally{
>             if(broker != null) broker.close();
>         }                       
>         return object;          
>  
> ------------------------repository
> -----------------------------------------------------
> <class-descriptor
>       class="my.com.shinyang.einout.business.bo.BrandBO"
>       table="brand">
>  
>       <field-descriptor id="1"
>          name="id"
>          column="brand_make"
>          jdbc-type="VARCHAR"
>          primarykey="true"         
>       />      
>       
>   </class-descriptor>
>  
> regards,
> Stephen
> 


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to