This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Doubt in Integrating Hibernate with Springframework  RSS feed

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am using Hibernate for persistence and I am using SimpleFormController in springmvc. I am developing a simple application to register a user. In my springconfiguration file I am configuring the properties as follows:




My doubt is that do I need to configure the hibernate properties :
hibernate.connection.url
hibernate.connection.driver_class
hibernate.connection.username
hibernate.connection.password

in

<property name="hibernateProperties">

</property>



as they are already configured in the dataSource property


Which one will be used. Please clear my concepts.
Thanks
 
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are setting the dataSource of the LocalSessionFactoryBean, then you don't need to set Hibernate's properties. You can set both, but the dataSource settings will override Hibernate's properties. To avoid confusion, you'd better not use Hibernate's properties in this case.
 
Siddharth Bhargava
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your help.
 
Siddharth Bhargava
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am using HibernateDaoSupport class for persistence in spring framework application.



But I am getting a NullPointerException in this line :


getHibernateTemplate().save(user);



Also where do I wire in my hibernateTemplate if I want to use my own hibernateTemplate which I have written in xml.

Please do help me
Thanks in advance.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All details can be found here
 
Siddharth Bhargava
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I read it already. It provides information about HibernaterTemplate not HiberDaoSupport. Please tell me why I am getting NullPointerException and where do i set the getHibernateTemplate().
Thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to set the sessionFactory like this :


It will automatically create a new HibernateTemplate, so you won't get a NullPointerException anymore.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!