Well, I am working on Spring with Hibernate. I am able to save values to my database using the HibernateTemplate's saveorupdate(). Now all I want is to display the values from the database tables onto my UI. I need the
JSP code as well as the changes that I have to make to My DAO to show the values.
Below is the DAO that I an using.
public class BulletinDAO {
private HibernateTemplate hibernateTemplate;
public HibernateTemplate getHibernateTemplate() {
return hibernateTemplate;
}
public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
this.hibernateTemplate = hibernateTemplate;
}
public void setSessionFactory(SessionFactory sessionFactory) {
this.hibernateTemplate = new HibernateTemplate(sessionFactory);
}
public BulletinBO getBulletin(Long id) {
return (BulletinBO) getHibernateTemplate().get(BulletinBO.class, id);
}
public List getBulletins() {
BulletinBO bulletinBO =new BulletinBO();
List bulletins = getHibernateTemplate().find("from BulletinBO");
bulletins.add(1);
bulletins.add(2);
bulletins.add(3);
for (int i=0; i<bulletins.size(); i++){
System.out.println(bulletins.get(i).toString());
}
return bulletins;
}
public void saveBulletin(BulletinBO bulletinBO) {
getHibernateTemplate().saveOrUpdate(bulletinBO);
}
public void removeBulletin(Long id) {
Object record = getHibernateTemplate().load(BulletinBO.class, id);
getHibernateTemplate().delete(record);
}
}
Here the BO extension means it is a business object.
Any help would be highly appreciated.
Thanks in advance
Bharat