• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Returning a meaniful result

 
Sege Stephen
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

org.dao.hibernate.GuestBook@3d808d
org.dao.hibernate.GuestBook@3faf33

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())

and





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
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
List pojoguestbook = guestbookDAO.findAll(GuestBook.class);System.out.println(pojoguestbook);



Why don't you try the following

 
Sege Stephen
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by satishkumar janakiraman:


Why don't you try the following




I did that and it didn't changed the result
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sege Stephen
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic