Hi,

The problem isn't that the constraint isn't being applied - it is, and it's 
working fine.  The problem is that we can't catch the exception gracefully.

For example:
 1) Create a user named 'bob'
 2) Create another user also called 'bob'

This generates an exception - which is fine.  The 'Caused by' will be 
java.sql.SQLException: Duplicate entry 'bob' for key 2.  I can catch the 
Exception in the Stateless Session Bean which is creating the user Entity Beans 
(org.hibernate.exception.ConstraintViolationException), but this doesn't stop 
the bubble of the Exception.  I next get the following in my log:

ERROR [AssertionFailure] an assertion failure occured (this may indicate a bug 
in Hibernate, but is more likely due to unsafe use of the session)

For example, If a Stateless Session Bean looks like this:


  | 
  | public boolean addUser(String username) {
  |   try {
  |     User newUser = new User(username);
  |     em.persist(newUser);
  |     return true;
  |   } catch (Exception e) {
  |     /* Ignore exception */
  |     return false;
  |   }
  | }
  | 

i would expect the method to return false in the event of a duplicate key 
insert...and that be the end of it.  But, what actually happens is a the 
AssertionFailure exception.

My guess is this is something to do with the underlying Hibernate session.  

What I'd like to do is stop the AssertionFailure exception from occuring.

Any help or ideas would be appreciated 

Thanks,

Jason

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3917666#3917666

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3917666


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to