This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
hiii, I make a small hibernate demo application with sapdb as backend. In which i have sucessfull in retrieving from database. But now i m inserting data in table. and for that i m using session.save(objectname of bean) and after that i have write transaction.commit() but because of commiting the transaction a exception is thrown which briefed below: Any help is appreciated:
description The server encountered an internal error () that prevented it from fulfilling this request.
This is just my first guess. with the save method if there already exists an equal record in the database for that table, then save will through an exception. If you call saveOrUpdate, then Hibernate will check to see if it needs an insert or an update statement.
you are using hibernate 2.x (net.sf.hibernate packages). can't you use hibernate 3.x (org.hibernate package structure) ?
anyway i'd sugest you create a testcase which is not based on struts (just a pure hibernate java app) and try to reproduce the problem. this is a NullPointerException occuring inside hiberante, hard to tell why this happens whitout seeing some code...
Just as an FYI, now that you are using Hibernate 3.0 there is a new feature that would make your use of
Session session = HibernateUtil.currentSession();
not needed, as you can now ge the current Session from the SessionFactory. with SessionFactory.getCurrentSession(). Since everyone seemed to be using that Util class with a currentSession, Hibernate team now included that kind of functionality in the Factory.
Anyway, you basic code you have should work. Do you have an ID field? It might also end up being something in you config file. But now with Hibernate 3 and JDK 5.0 you can now use Annotations.
Joined: Jun 05, 2006
hiii, i got the solution by flushing session before transaction commmited,but why this thing is needed plz tell if anyone knows.