Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring 3.0 and Hibernate newbie question

 
Todd Smith
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to select data from 2 tables using hibernate and display it on a JSP. He is my question. The 2 tables have a common key. how is the best way to join them and Also it is a one to many. so I need to display some of table 1 data on the JSP and I may have one more more rows return from the secound table. I get Confused when I think about returning the model and View and I need to return to one object for the top of the jsp and a List of objects for the bottom of the JSP. Can any one please give me some type of direct on my issue. I don't really understand how to return 2 diffrent object in the modelandview to the JSP.

Thanks
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Todd Smith wrote:I need to select data from 2 tables using hibernate and display it on a JSP. He is my question. The 2 tables have a common key. how is the best way to join them and Also it is a one to many. so I need to display some of table 1 data on the JSP and I may have one more more rows return from the secound table. I get Confused when I think about returning the model and View and I need to return to one object for the top of the jsp and a List of objects for the bottom of the JSP. Can any one please give me some type of direct on my issue. I don't really understand how to return 2 diffrent object in the modelandview to the JSP.

Thanks


For your Hibernate query, you will need to post that into our ORM forum.

For ModelAndView object, the Model portion is just a map, so you add() to the ModelAndView and give each a name

modelAndView.add("firstTable", firstTableData);
modelAndView.add("secondTable", secondTableData);

return modelAndView;

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