This content has been marked as final.
Show 3 replies
-
1. Re: 'no-select-before-insert'
jivkoto Oct 12, 2006 10:23 AM (in response to gabrielbianco)The code that generates this log is from class org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand and more specifically in method protected void performInsert(EntityEnterpriseContext ctx) throws CreateException. Here is the snippet that is logging.
?.. catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } ?. }
log object is org.jboss.logging.Logger instance.
The only way that I find is not to log log level ERROR, which is too hard. Or just make feature request this logging to be changed from ERROR to WARN level. I am wondering why this is ERROR? Exception is thrown and it will not be left unnoticed, why explicitly logging is needed? If this is because throw new CreateException(??"); hides the original message and stack trace, this could be changed, too.
Is there anyone with good explanation?
Best Regards, jivkoto -
2. Re: 'no-select-before-insert'
bartvh May 7, 2007 10:29 AM (in response to gabrielbianco)This error log is indeed very annoying. But to me, the fact that a generic CreateException is thrown is even more problematic. How do I distinguish this from some other failure in the database? I would hope I do not need to interpret the exeception's message to distinguish.
Shouldn't this code read as:catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { throw new DuplicateKeyException( "Integrity constraint violation:" + e.getMessage()); } ... }
-
3. Re: 'no-select-before-insert'
swjackson May 8, 2007 2:11 PM (in response to gabrielbianco)}catch( Exception e){
Throwable t = e.getCause();
Class tclass = t.getClass();
if( tclass.isAssignableFrom(IllegalArgumentException.class)){
System.err.println("illegal exception ");
}
}