File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes Doubt in Integrating Hibernate with Springframework Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Doubt in Integrating Hibernate with Springframework" Watch "Doubt in Integrating Hibernate with Springframework" New topic
Author

Doubt in Integrating Hibernate with Springframework

Siddharth Bhargava
Ranch Hand

Joined: Feb 23, 2007
Posts: 257
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
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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.


[My Blog]
All roads lead to JavaRanch
Siddharth Bhargava
Ranch Hand

Joined: Feb 23, 2007
Posts: 257
Thanks a lot for your help.
Siddharth Bhargava
Ranch Hand

Joined: Feb 23, 2007
Posts: 257
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

All details can be found here
Siddharth Bhargava
Ranch Hand

Joined: Feb 23, 2007
Posts: 257
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

You need to set the sessionFactory like this :


It will automatically create a new HibernateTemplate, so you won't get a NullPointerException anymore.
 
 
subject: Doubt in Integrating Hibernate with Springframework
 
Similar Threads
Hiberante transaction in Spring
java.sql.SQLException: No suitable driver
login form with database and spring security
NPE at getHibernateTemplate( )
MappingException occured