aspose file tools
The moose likes Object Relational Mapping and the fly likes null pointer exception in spring with hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "null pointer exception in spring with hibernate" Watch "null pointer exception in spring with hibernate" New topic
Author

null pointer exception in spring with hibernate

sanu jony
Greenhorn

Joined: Oct 11, 2004
Posts: 8
hi friend,
while i am trying to perform data access by using hibernate in spring frame work i am getting the following exception. my "getHibernateTemplate()" in DAO is passing a null value.
anybody knows the solution for this please help me.


java.lang.NullPointerException
bus.userDAO.saveitem(userDAO.java:34)
bus.PriceIncreaseValidator.validate(PriceIncreaseValidator.java:30)
org.springframework.validation.ValidationUtils.invokeValidator(ValidationUtils.java:49)
org.springframework.web.servlet.mvc.BaseCommandController.bindAndValidate(BaseCommandController.java:260)
org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:235)
org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:119)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:389)
org.springframework.web.servlet.FrameworkServlet.serviceWrapper(FrameworkServlet.java:339)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:325)
javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Looks like you are trying to use a null object in your DAO. Of course without seeing the code I can't be sure.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
sanu jony
Greenhorn

Joined: Oct 11, 2004
Posts: 8
Hi Paul Sturrock
this error came while i was trying to insert a value to the table named Item,
my DAO code is given bellow

public class userDAO extends HibernateDaoSupport{
private Item item;
public void setItem(Item item)
{ this.item = item;
System.out.println("<<<<item.getDescription()1>>>");
System.out.println(item.getDescription());
}

public void findGroupByName(String name) {
getHibernateTemplate().save(item);
}
public void saveitem()
{
System.out.println("item.getDescription()200");

System.out.println(getHibernateTemplate());
getHibernateTemplate().save(item);
}

}

here i am getting the item(from POJO) values which i am passing from a jsp page.
but getHibernateTemplate() is returning a null value.
please tell me if u know the solution
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: null pointer exception in spring with hibernate
 
Similar Threads
Connection to the database Failure
Getting java.lang.NoSuchMethodError
unique key hibernate exception
Error Reading data from database
Request processing failed; nested exception is org.springframework.beans.InvalidPropertyException: