Im getting an error which may have something to do with my hibernate code
Code:
org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: Could not save object; bad SQL grammar []; nested exception is java.sql.SQLException: Table not found in statement [select next_hi from hibernate_unique_key for update]
Any ideas? What im trying to do is save an object to the table and im doing it like this in the dao
Code:
public void addPhotoinfo(Photo p) {
getHibernateTemplate().save(p);
}
my complete dao
Code:
package src.db;
import java.util.List;
import org.springframework.orm.hibernate.support.HibernateDaoSupport;
import src.bus.Photo;
public class PhotoDaoHib extends HibernateDaoSupport implements PhotoDao {
public Photo getPhotoinfo(int id) {
return (Photo) getHibernateTemplate().load(Photo.class, id);
}
public List getPhotoinfoList() {
return getHibernateTemplate().find("from Photo p");
}
public void addPhotoinfo(Photo p) {
getHibernateTemplate().save(p);
}
}
and where i call the dao (controller)
Code:
package src.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.view.RedirectView;
import src.bus.Photo;
import src.bus.PhotoManager;
public class PhotoinfoController extends SimpleFormController{
private PhotoManager pm;
protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response, Object command, BindException errors) {
Photo bean = (Photo)command;
pm.setPhoto(bean); // write collected form data to the database table
//return super.onSubmit(request, response, command, errors);
return new ModelAndView(new RedirectView(getSuccessView()));
}
public PhotoManager getPhotoManager() {
return pm;
}
public void setPhotoManager(PhotoManager pm) {
this.pm = pm;
}
}