• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubt in Integrating Hibernate with Springframework

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your help.
 
Siddharth Bhargava
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All details can be found here
 
Siddharth Bhargava
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic