• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to display DB table values?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bharat,
Welcome to JavaRanch!

Hibernate questions go in our O/R forum; I'll move this for you.
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Oh. Hi guys! Look at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic