• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Hibernate SessionFactory Problem

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a JSP/Struts/JDBC developer starting my first Spring/Hibernate project.

I've read many of the docs and downloaded several examples and got them running. I'm now trying to convert one of the Spring examples to use Hibernate. For those interested, I'm converting the "Spring MVC Fast Tutorial" found at http://maestric.com/doc/java/spring - SpringMVC is #3.

I successfully got the WAR deployed, but it's failing when trying to get the hibernateTemplate from the sessionFactory. During deployment the log shows that the hibernateTemplate was created but later, from my view, when I try to use hibernateTemplate.find( ) the object is null.

So, I guess I have not correctly constructed the bean that creates the sessionFactory and makes it persistent.

I add the relevant code below, but for those that want to see the full project and log you can download it from here: http://carpenterdev.com/files/myspringmvc.zip

Thanks for your help in solving this!

--Bob
 
Bob Carpenter
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm the original poster.

I edited the posting because I pasted the wrong Car.hbm.xml code.

If you read the earlier post and the Car.hbm.xml part didn't make sense, it should now.

Thanks,

--Bob
 
Bob Carpenter
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I decided to give up on using HibernateDaoSupport and instead use a plain hibernate3 api.

This means that in my DAOImpl classes, where I need to get a hibernateTemplate I use an applicationContext to get the sessionFactory bean, like this:


--Bob
 
See where your hand is? Not there. It's next to this tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!