I am new with this. Please help me.
My controller for listing looks like this:
@RequestMapping(value="/possalesList.htm",method=RequestMethod.GET)
public String PosSalesList(@ModelAttribute("possales")PSales sales,@RequestParam(value = "salesItemID", required = false)Integer salesItemID,ModelMap model)
{
List<POSSalesItem> posSalesItemList = posSalesDao.listSalesItem();
model.addAttribute("possalesList", posSalesItemList);
return "possalesList";
}
My hibernateDaoimpl looks like this:
@SuppressWarnings("unchecked")
@Transactional(readOnly=true)
public List<POSSalesItem> listSalesItem() {
return (List<POSSalesItem>)getHibernateTemplate().find("select POSSales.posSalesId , POSSalesItem.itemName from POSSales inner join POSSalesItem on POSSales.posSalesId=POSSalesItem.posSalesId");
}
My inner join looks like this:
select POSSales.posSalesId , POSSalesItem.itemName from POSSales inner join POSSalesItem on POSSales.posSalesId=POSSalesItem.posSalesId
the foreign key is created successfully in mysql.
what i am doing is i am listing posSalesId from POSSales table and other columns from POSSalesItem .for that purpose i have written this join query but its showing some error.
I want to make the inner join on the column posSalesId, but I get these errors:
org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: on near line 1, column 111 [select POSSales.posSalesId , POSSalesItem.itemName from com.jewellery.entity.POSSales inner join POSSalesItem on POSSales.posSalesId=POSSalesItem.posSalesId]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: on near line 1, column 111 [select POSSales.posSalesId , POSSalesItem.itemName from com.jewellery.entity.POSSales inner join POSSalesItem on POSSales.posSalesId=POSSalesItem.posSalesId] org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:660) org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412) org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411) org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)