-
FEATURED COMPONENTS
First time here? Check out the FAQ!
*** ANSWERED/SOLVED ***
Hi all,
I had a problem with a class with a many-to-one relation not comiting : here
Since then i manage my transaction myself and my application seem to work well (in test at least). But i got this exception (seem like its coming from ZK invokeExecutionCleanups and ZK OpenSessionInViewListener) in console and i asking myself why ?
I begin a new transaction each time like that:
public void saveOrUpdate(HeuresEffectuees desHeuresEffectuees) { Session sess = currentSession(); Transaction tx = sess.beginTransaction(); sess.saveOrUpdate(desHeuresEffectuees); tx.commit(); }
@bob007
Hi Bob,
sorry but this is absolut not for the ZKoss Forum. Have a look at the Hibernate Forums.
There you became surely the right help.
But: Please do a try/catch. What should happens when the commit is failed???
not tested code
try{ Session sess = currentSession(); Transaction tx = sess.beginTransaction(); sess.saveOrUpdate(desHeuresEffectuees); tx.commit(); } catch (Exception e){ sysout(e); tx.rollback(); sess.close(); ??? }
whishes
Stephan
I don't think its my commits who raise the exception.
It seem more like its the ZK invokeExecutionCleanups and ZK OpenSessionInViewListener.
2009-03-05 11:45:14 org.zkoss.zk.ui.util.Configuration invokeExecutionCleanups:831 GRAVE: Failed to invoke class org.zkoss.zkplus.hibernate.OpenSessionInViewListener ... at org.zkoss.zkplus.hibernate.OpenSessionInViewListener.cleanup(OpenSessionInViewListener.java:65) at org.zkoss.zk.ui.util.Configuration.invokeExecutionCleanups(Configuration.java:828) ...
hmmm,
sorry i don't know. My hibernate is managed by spring.
bob,
the exception recall me something, I think you should not 'beginTransaction' for currentSession and 'commit' it.
because OpenSessionInViewListener already did it.
About many-to-on didn't commit issue, I am wondering , it is a hibernate( mapping configuration ) issue or ZK event thread issue.
Did you disable the event thread of ZK of your application.
@dennis
thanks for your answer,
No i didnt disable the event thread of ZK and my other commiting are working.
Are you sure i should not use transaction begin/commit in ZK ?
Is there another way to force ZK to commit then ?
I really really dont know what to do now, i'm on this since a few days and my work start to get late.
bobo,
I didn't have enough information(the code/the logic) about your application to know what is the problem,
and I still think this is the usage problem of hibernate.
1.call session.flush() before saveOrUpdate();(don't call beginTransaction() and commit, )
2.can you try to disable event thread to see if it work or not.
if still no work, please post a reproducible code here(as simple as possible, please) (there will be many files in you case)
/Dennis
Please also check if there is any exception when you do the update , because exception will trigger rollback.
@Dennis
Thanks for your answer,
No I don't get any exception for the update.
Are you totally sure I can't / shouldn't use transaction begin/commit ?
I wanted as many confirmation as possible because only two people answered me : one said Yes and the other said No.
I was wondering if I do it with transaction begin/commit :
Since the problem for org.zkoss.zkplus.hibernate.OpenSessionInViewListener.cleanup
is "Transaction not successfully started" maybe i put a sess.beginTransaction(); just after my commits maybe it will solve the problem ?
Can it work ?
Steve
Bob,
I don't have your application and did have enough information about the application logic/detail.
It will spend me too much time to "GUESS" what happened in your application.
Maybe a small tricky code/configuration cause this error, but I don't know since I am not a member in the project, I don't have the code to trace.
So, If you can do some filtering to remove some unnecessary code, provide a simple reproducible code (doesn't have many business logic/object)
It will help me to help you solve the problem.
:)
/Dennis
Bob, please also provide the implementation of hashCode() and equals() of the persistence object HeuresEffectuees
Asked: 2009-03-05 17:12:23 +0800
Seen: 3,293 times
Last updated: Aug 28 '12