Thanks for the solution. But I don't want to write the sql query in the java code.
Is there any way to achieve this? -- why don't we provide a way to restrict the columns while fetching the data? Ex: object having set of columns from which want fetch the data for only few columns...using the object entity. Thanks, Sampath Uppula -----Original Message----- From: Felipe Martín Santos [mailto:[email protected]] Sent: Tuesday, October 30, 2012 4:40 PM To: [email protected] Subject: Re: Problem - fetching the Distinct rows based on a Property // Extract is the obj-entity you have for the T_QC_EXTRACT db-entity SQLTemplate query = new SQLTemplate(Extract.class, "SELECT DISTINCT STORY_ID FROM T_QC_EXTRACT WHERE EXECUTION_STATUS IN ('PASSED','BLOCKED')"); SQLResult resultDescriptor = new SQLResult(); resultDescriptor.addColumnResult("STORY_ID"); query.setResult(resultDescriptor); List<DataObject> dataObjects = context.performQuery(query); Is this what you need?? You can see more here: http://cayenne.apache.org/doc/sqltemplate-result-mapping.html 2012/10/30 Sampath Uppula <[email protected]> > Hi, > > I have a table T_QC_EXTRACT with many columns, few of them are STORY_ID, > EXECUTION_STATUS. > I want to fetch the distinct STORY_ID based on EXECUTION_STATUS IN > ('PASSED','BLOCKED'); > > SELECT DISTINCT STORY_ID FROM T_QC_EXTRACT WHERE EXECUTION_STATUS IN > ('PASSED','BLOCKED'); > > Please suggest a way to achieve this using Cayenne. > > Thanks, > Sampath Uppula > > ============================================================================================================================Disclaimer: > This message and the information contained herein is proprietary and > confidential and subject to the Tech Mahindra policy statement, you may > review the policy at <a href="http://www.techmahindra.com/Disclaimer.html > ">http://www.techmahindra.com/Disclaimer.html</a> externally and <a href=" > http://tim.techmahindra.com/tim/disclaimer.html"> > http://tim.techmahindra.com/tim/disclaimer.html</a> internally within > Tech > Mahindra.============================================================================================================================ ============================================================================================================================Disclaimer: This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review the policy at <a href="http://www.techmahindra.com/Disclaimer.html">http://www.techmahindra.com/Disclaimer.html</a> externally and <a href="http://tim.techmahindra.com/tim/disclaimer.html">http://tim.techmahindra.com/tim/disclaimer.html</a> internally within Tech Mahindra.============================================================================================================================
