aspose file tools*
The moose likes Object Relational Mapping and the fly likes How to display DB table values? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to display DB table values?" Watch "How to display DB table values?" New topic
Author

How to display DB table values?

bharat patel
Greenhorn

Joined: Sep 26, 2007
Posts: 1
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

Joined: May 26, 2003
Posts: 31074
    
232

Bharat,
Welcome to JavaRanch!

Hibernate questions go in our O/R forum; I'll move this for you.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jason Ferguson
Ranch Hand

Joined: Sep 16, 2007
Posts: 47
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

Joined: Feb 05, 2001
Posts: 17260
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to display DB table values?