Skip to content

Instantly share code, notes, and snippets.

@bittersweetryan
Created August 23, 2011 20:24
Show Gist options
  • Save bittersweetryan/1166407 to your computer and use it in GitHub Desktop.
Save bittersweetryan/1166407 to your computer and use it in GitHub Desktop.
Today's Code Fail
public List findByProjectContractDetailId(Long contractDetailID) {
logger.info("finding all ContractTaskDetail instances");
try {
String queryString = "from ContractTaskDetail";
Query queryObject = getSession().createQuery(queryString);
List contractTaskDetailList = queryObject.list();
//um...queryObject.list returns nearly 1000000 rows hows about we write a freaking
//WHERE clause
for(Iterator it=queryObject.list().iterator(); it.hasNext(); )
{
ContractTaskDetail contractTaskDetail =(ContractTaskDetail)it.next();
if(contractTaskDetail.getId().getProjectContractDetailID().compareTo(value1) == 0)
{
} else {
contractTaskDetailList.remove(contractTaskDetail);
}
};
return contractTaskDetailList;
} catch (RuntimeException re) {
logger.warning("find all failed", re);
throw re;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment