Re: Exception handling after violation of unique constraint

2009-09-13 Thread Geoff Callender
Agreed. Any number of exceptions can occur when you commit, regardless of what queries you've run in the same transaction. That's the nature of multi-user systems, unless of course you want to set the transaction isolation level to serialize (not usually recommended). As for using onValida

Re: Exception handling after violation of unique constraint

2009-09-12 Thread Hilco Wijbenga
2009/9/12 Thiago H. de Paula Figueiredo : > Em Sat, 12 Sep 2009 17:38:43 -0300, Bruno Santos > escreveu: > >> Well, even if i do: >> >> league = new League(); >> league.setName("repeated name"); > > Unique constraints like this should be checked by you *before* sending an > insert or update to the

Re: Exception handling after violation of unique constraint

2009-09-12 Thread Thiago H. de Paula Figueiredo
Em Sat, 12 Sep 2009 17:38:43 -0300, Bruno Santos escreveu: Well, even if i do: league = new League(); league.setName("repeated name"); Unique constraints like this should be checked by you *before* sending an insert or update to the database. -- Thiago H. de Paula Figueiredo Independen

Re: Exception handling after violation of unique constraint

2009-09-12 Thread Bruno Santos
Well, even if i do: league = new League(); league.setName("repeated name"); I still have same problem, even without that piece of code. Everything works fine with Create/Update of entity if saveorupdate doesn't violate any constraint. On Sat, Sep 12, 2009 at 7:34 PM, Kalle Korhonen wrote: > Y

Re: Exception handling after violation of unique constraint

2009-09-12 Thread Kalle Korhonen
Yes, but the problem originates from this: if (entity.getId().longValue() == 0l) { league.setId(null); } You can't make that league object a new entity just by nullifying it's id. Try creating a new league if you need to. Later on, since the save

Re: Exception handling after violation of unique constraint

2009-09-12 Thread Bruno Santos
The question is i'm not trying to flush anything, i do (through DAO) session.saveOrUpdate, catch the exception and the only thing i do besides registering the error on the form is returning this (the page i'm at) wich causes (i guess) tapestry to query database to fill data for selectmodels. And, a

Re: Exception handling after violation of unique constraint

2009-09-11 Thread Kalle Korhonen
On Fri, Sep 11, 2009 at 7:26 PM, Thiago H. de Paula Figueiredo wrote: > Em Fri, 11 Sep 2009 23:11:59 -0300, Kalle Korhonen > escreveu: > I think onValidate() is for validation, the data store should only be > changed (or attepted to be changed) when validation succeeds and controller > classes (b

Re: Exception handling after violation of unique constraint

2009-09-11 Thread Thiago H. de Paula Figueiredo
Em Fri, 11 Sep 2009 23:11:59 -0300, Kalle Korhonen escreveu: Interesting - I happen to think it's a great pattern to follow. You try to save and then roll back if it didn't work out - that's what the transaction management is for and Tapestry gives you a very nice way to accomplish this easil

Re: Exception handling after violation of unique constraint

2009-09-11 Thread Kalle Korhonen
On Fri, Sep 11, 2009 at 3:05 PM, Thiago H. de Paula Figueiredo wrote: > Em Fri, 11 Sep 2009 18:30:34 -0300, Bruno Santos > IMHO, you have to write code to do that (query the database if needed) Well that doesn't do anything else except merely lowers the probability. > intead of sending data to

Re: Exception handling after violation of unique constraint

2009-09-11 Thread Kalle Korhonen
I'm using the plain hibernate Session (shadow) and the pattern works great for me. But I think your problem is actually in "(don't flush the Session after an exception occurs)". You are doing something odd since you need to nullify the id. For a new object, the id should normally be null. Tapestry

Fwd: Exception handling after violation of unique constraint

2009-09-11 Thread Bruno Santos
Hit wrong button i guess, sent message only to Sven. Sorry -- Forwarded message -- From: Bruno Santos Date: Fri, Sep 11, 2009 at 11:19 PM Subject: Re: Exception handling after violation of unique constraint First i like to thank you (both) for your patience and help. Well, not

Re: Exception handling after violation of unique constraint

2009-09-11 Thread Thiago H. de Paula Figueiredo
Em Fri, 11 Sep 2009 18:30:34 -0300, Bruno Santos escreveu: Hello, Hi! Well, the reason should be that with persist in validate() i validate that the entity that's inserted doesn't conflict with any database constraint like in this case and the onsucess isn't fired wich in the case a const

Re: Exception handling after violation of unique constraint

2009-09-11 Thread Bruno Santos
Hello, Well, the reason should be that with persist in validate() i validate that the entity that's inserted doesn't conflict with any database constraint like in this case and the onsucess isn't fired wich in the case a constraint is violated it doesn't seem to make sense. Anyway, even if i use

Re: Exception handling after violation of unique constraint

2009-09-11 Thread Sven Homburg
what is your reason, that you want to persist the enity in the validation event? i think its more clear to persist it in the onSuccess event method with regards Sven Homburg Founder of the Chenille Kit Project http://www.chenillekit.org 2009/9/11 Bruno Santos > Thanks for your answer, i lea

Exception handling after violation of unique constraint

2009-09-11 Thread Bruno Santos
Thanks for your answer, i learned a bit more of tapestry. Now i have one more problem, not exactly related but in the same area. I have void onValidateForm() { if (entity.getId().longValue() == 0l) { league.setId(null); }