-
1. Re: unique constraint & TransactionRolledbackLocalException
tomerbd Aug 19, 2004 12:39 PM (in response to tomerbd)Could it be a cache thing? That my transaction was commited but not to the database ? if so, then How can I konw if my setAlias succeeded or failed?
-
2. Re: unique constraint & TransactionRolledbackLocalException
tomerbd Aug 19, 2004 12:40 PM (in response to tomerbd)Rolled back ofcourse :) ... why didnt i catch that exception in the testUnique() method ?
-
3. Re: unique constraint & TransactionRolledbackLocalException
sbrbot Aug 20, 2004 4:58 AM (in response to tomerbd)If you want to check before inserting new user whether the user with this alias already exist, you should create home test (finder or even better select) method findByAlias(String Alias) which will use EJBQL fo find user with this alias. Insert your new user only upon FinderException of findByAlias().
Second approach could be to try insert your new user with its unique or not-unique alias and catch JDBC's SQLException if DB complaints regarding its unique constraint. -
4. Re: unique constraint & TransactionRolledbackLocalException
tomerbd Aug 20, 2004 5:18 AM (in response to tomerbd)Truely, that was my second option, I wanted to use CMP's + My database capabilities to automatically detect such state, however it seems like it cant be done. I'm interested to know why wasnt the exception thrown at the right point ? (at the end of the method that had a required transaction).