Re: [appfuse-user] Exception thrown when a unique field in database is duplicate

2010-05-07 Thread Dusty Pearce
Not really a problem, I was just curious. There are lots of patterns for creating puesdo-puesdo-random-numbers, and it seems like using the database is expensive for that function. It depends on the purpose of the random number and the scale and performance of the app I guess.It's really

Re: [appfuse-user] Exception thrown when a unique field in database is duplicate

2010-05-06 Thread Juan Antonio Calderón
That's what i do, perhaps i didn't explain myself very well. :D Doing a lookup searching if there is a duplicate it's almost the same (make a loop, find by the field, catch the "NoSuch..."), almost the same complicated... My "only" problem here was to know the exception thrown (in struts 1 i used

Re: [appfuse-user] Exception thrown when a unique field in database is duplicate

2010-05-06 Thread Dale Newfield
On 5/6/10 10:57 AM, Juan Antonio Calderón wrote: Is not an object "key", is a property in a model java class, an unique field in the database :) I have to try it, to know if there is a duplicate field. Any other way? ;) You could always try to do a lookup based on that potential unique value

Re: [appfuse-user] Exception thrown when a unique field in database is duplicate

2010-05-06 Thread tibi
i don't get the problem. you have an object with a field which is unique than make the object, save it using a dao, catch the exception. if it is something with unique constrain than you know... tibi Quoting Juan Antonio Calderón : Is not an object "key", is a property in a model java cla

Re: [appfuse-user] Exception thrown when a unique field in database is duplicate

2010-05-06 Thread Juan Antonio Calderón
Is not an object "key", is a property in a model java class, an unique field in the database :) I have to try it, to know if there is a duplicate field. Any other way? ;) Thanks everybody. 2010/5/6 Dustin Pearce > Are you generating a random number for the object "key" and then seeing if > it

Re: [appfuse-user] Exception thrown when a unique field in database is duplicate

2010-05-06 Thread tibi
i would write a test and see what happens ;) Quoting Juan Antonio Calderón : Maybe DataIntegrityViolationException could be used, like in UserManagerImpl.java? Thanks. 2010/5/6 Juan Antonio Hello everybody. I have a problem. I generate a random field, that must be unique, and i need

Re: [appfuse-user] Exception thrown when a unique field in database is duplicate

2010-05-05 Thread Dustin Pearce
Are you generating a random number for the object "key" and then seeing if its already there and trying again...and again...? Just curious. -D On May 5, 2010, at 7:17 PM, Juan Antonio Calderón wrote: > Maybe DataIntegrityViolationException could be used, like in > UserManagerImpl.java? > > T

Re: [appfuse-user] Exception thrown when a unique field in database is duplicate

2010-05-05 Thread Matt Raible
Yes, this is the recommended exception to catch. 2010/5/5 Juan Antonio Calderón > Maybe DataIntegrityViolationException could be used, like in > UserManagerImpl.java? > > Thanks. > > 2010/5/6 Juan Antonio > > >> Hello everybody. >> >> I have a problem. >> >> I generate a random field, that must

Re: [appfuse-user] Exception thrown when a unique field in database is duplicate

2010-05-05 Thread Juan Antonio Calderón
Maybe DataIntegrityViolationException could be used, like in UserManagerImpl.java? Thanks. 2010/5/6 Juan Antonio > > Hello everybody. > > I have a problem. > > I generate a random field, that must be unique, and i need to catch the > exception thrown in the save() method in the DAO. > > What is

[appfuse-user] Exception thrown when a unique field in database is duplicate

2010-05-05 Thread Juan Antonio
Hello everybody. I have a problem. I generate a random field, that must be unique, and i need to catch the exception thrown in the save() method in the DAO. What is the exception thrown? Is an HibernateException, a RuntimeException...? I used to catch an ConstraintViolationException, could be