AdminController.java
@Controller
public class AdminController {
@Autowired
HttpServletRequest request;
@Autowired
AdminDao adminDao;
@RequestMapping("/deletebatch")
public String deletebatch(){
int batchid = Integer.parseInt(request.getParameter("id"));
adminDao.deletebatch(batchid);
return "redirect:/viewbatch";
}
#AdminDaoImpl.java
@Repository("adminDao")
public class AdminDaoImpl implements AdminDao {
@Autowired
SessionFactory sessionFactory;
@Transactional
public void deletebatch(int batchid){
// Batch batch = (Batch) sessionFactory.getCurrentSession().load(Batch.class,batchid);
// if(batch!=null){
sessionFactory.getCurrentSession().delete(batchid);
//}
}
}
#viewbatch.jsp
<form >
<table border="1">
<tr>
<th>BATCH id</th>
<th>BATCH name</th>
<th>edit/delete</th>
</tr>
<c:forEach items="${batchlist}" var="batchlist">
<tr>
<td>${batchlist.batchid}</td>
<td>${batchlist.batchname}</td>
<td><a href="edit">edit</a>/<a href="${pageContext.servletContext.contextPath}/deletebatch?id=${batchlist.batchid}">delete</a></td>
</tr>
</c:forEach>
When i try to delete i got the error :
HTTP Status 500 - Request processing failed; nested exception is org.hibernate.MappingException: Unknown entity: java.lang.Integer"
and
i try putting the admincontroller as "/delete?id=${batchid}" also.
While i did this i got the problem like can't convert to string