Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to display DB table values?

 
bharat patel
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bharat,
Welcome to JavaRanch!

Hibernate questions go in our O/R forum; I'll move this for you.
 
Jason Ferguson
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bharat,

Take a look at the DisplayTag library: http://displaytag.sourceforge.net.

DisplayTag will take a Collection object and output it into an HTML table in a JSP. I _think_ this is what you are asking.

Jason
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, it kind of looks like two different questions here. One that is ORM related to query the database and get data, but the displaying in on a JSP page should be asked in the JSP forum.

I am not moving this thread, but understand that you probably won't get the JSP portion of the question answered here and that you might need to post that part of the question in the JSP forum.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic