File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Returning a meaniful result Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Returning a meaniful result " Watch "Returning a meaniful result " New topic

Returning a meaniful result

Sege Stephen
Ranch Hand

Joined: Oct 06, 2007
Posts: 51
I hope this is in the right thread because it leans toward Java more than hibernate.

Here is my problem, I am returning and printing a list of comments from a Guestbook.

code in my DAO class

code in my action class

This is what I am getting as results, this result is being read from the database.


I need meaniful result and I believe I have to override toString(). I have tried several methods and still not yet able to come up with the proper result.

two things I have tried was

to add System.out.println(pojoguestbook.toString())


I ran into problem with the latter, as all the examples I found, the setters and getter were in the same class, but here my setter and getters are not in my action class.

Please help.
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
List pojoguestbook = guestbookDAO.findAll(GuestBook.class);System.out.println(pojoguestbook);

Why don't you try the following

Sege Stephen
Ranch Hand

Joined: Oct 06, 2007
Posts: 51
Originally posted by satishkumar janakiraman:

Why don't you try the following

I did that and it didn't changed the result
Rob Spoor

Joined: Oct 27, 2005
Posts: 20271

For which class did you overwrite the toString method? org.dao.hibernate.GuestBook? Or some other class?

The elements of your list are instances of org.dao.hibernate.GuestBook, as can be seen from the result. It's that class' toString method that you need to override.

How To Ask Questions How To Answer Questions
Sege Stephen
Ranch Hand

Joined: Oct 06, 2007
Posts: 51
Rob Prime, thanks a lot. It was all about overriding my toString() in the right class. I thought it should be in my Action class where the code logic is , but once I put in the class which contains the setter and getters, it worked.

I agree. Here's the link:
subject: Returning a meaniful result
It's not a secret anymore!