0

Hibernate Session Handling

asked 2010-01-13 00:12:40 +0800

natoosandeep gravatar image natoosandeep
45

Hi ,
we are using hibernate for our project for that purpose we go with the zk 's session handler.
Its going good , but now we also want that the status of our last transaction(is it commited or rollback) ?
How we will get that please help.
Thanks !

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2010-01-15 00:24:32 +0800

joylo0122 gravatar image joylo0122
688 1
www.zkoss.org

@natoosandeeop

Hi natoosandeeop, what you means the status you want? For the lastest transaction?
In our zk session handler, i don't think it will save these informations, it should be design by developer.
There's a lot of way can do this, ex. log it out to a file, and check the file every time you want the
information.

/Joy

link publish delete flag offensive edit

answered 2010-01-15 02:43:55 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2010-01-15 02:46:04 +0800

try {
saveOrUpdate(aObject)
tx.commit

}
catch (Exception e) {

 tx.rollback;
 Messagebox.show(e.toString());

}


best
Stephan

link publish delete flag offensive edit

answered 2010-01-17 23:32:43 +0800

spideyh2003 gravatar image spideyh2003
3

Hello Stephan(terrytornado)

I tried your code.. but it wont work.. i also want to have a rollback or commit but it seems that you cant do that in the hibernate+ZK implementation :(

here is my code example...

public class ClientDAO {
	Session _session;
	
	public ClientDAO() {
		_session = HibernateUtil.getSessionFactory().getCurrentSession();
	}

	public void saveOrUpdate() {
		Object1 obj1 = new Object1();
		obj1.setClientNumber("2222222");
		obj1.setFirstName("Donato");
		obj1.setLastName("Baonguis");
		
		Object2 obj2 = new Object2();
		obj2.setClientNumber("1111111");
		obj2.setFirstName("Joy");
		obj2.setFirstName("Fernandez");

		Transaction tx = _session.beginTransaction();
		try {
			_session.save(obj1);
			_session.save(obj2);
			tx.commit();
		} catch(Exception e) {
			tx.rollback();
		}
	}
}


what i wanted to achieve is that IF line "_session.save(obj1);" OR line "_session.save(obj2);" generates an error, then NONE should be saved or commited. However, it still saves one or the other :(( and it just generates the error below on the console...
SEVERE: Failed to invoke class org.zkoss.zkplus.hibernate.OpenSessionInViewListener
org.hibernate.TransactionException: Transaction not successfully started 

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-01-13 00:12:40 +0800

Seen: 367 times

Last updated: Jan 17 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More