aspose file tools*
The moose likes Spring and the fly likes Spring 3.0 and Hibernate newbie question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring 3.0 and Hibernate newbie question" Watch "Spring 3.0 and Hibernate newbie question" New topic
Author

Spring 3.0 and Hibernate newbie question

Todd Smith
Greenhorn

Joined: Dec 16, 2010
Posts: 25
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

Joined: Feb 05, 2001
Posts: 17259
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Spring 3.0 and Hibernate newbie question