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.
i have used saveorupdate it has problem "afterTransactionCompletion() was never called" message on server and no change in database
pascal betz
Ranch Hand
Joined: Jun 19, 2001
Posts: 547
posted
0
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...
Can you post the code form when you create the Session to closing the session?
Thanks
Mark
Pankaj Chaudhary
Greenhorn
Joined: Jun 05, 2006
Posts: 16
posted
0
hiii, now i am using hibernate3 package. now i have a exception on server like this
No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/apache-tomcat-5.5.12/webapps/quickstart/WEB-INF/lib/ehcache-0.7.jar!/ehcache-failsafe.xml
and when i used select query then data is retieved. but in case of inserting data no error is there but data doesnot save in table.
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.
Mark
Mark
Pankaj Chaudhary
Greenhorn
Joined: Jun 05, 2006
Posts: 16
posted
0
hiii, i got the solution by flushing session before transaction commmited,but why this thing is needed plz tell if anyone knows.