Antonio's team hired some very expensive contractors and consultants to help them build a Java based application. These contractors were very demure, very mindful, about how using ORMs could kill performance.

So they implemented a tool that would let them know any time the Hibernate query generator attempted to perform a cross join.

public class DB2390Dialect extends org.hibernate.dialect.DB2390Dialect
{
 private Logger logger = LoggerFactory.getLogger(DB2390Dialect.class);

 @Override
 public String getCrossJoinSeparator()
 {
  try
  {
   Exception e = new Exception();
   throw e;
  }
  catch (Exception xe)
  {
   logger.warn("cross join ", xe.getMessage());
  }
  return ", ";
 }
}

I'm going to call this one a near miss. I understand what they were trying to do.

Hibernate uses a set of "dialect"s to convert logical operations in a query to literal syntax- as you can see here, this function turns a cross join operation into a ", ".

What they wanted to do was detect where in the code this happened and log a message. They wanted the message to contain a stack trace, and that's why they threw an exception. Unfortunately, they logged, not the stack trace, but the message- a message which they're not actually setting. Thus, the logger would only ever log "cross join ", but with no information to track down when or why it happened.

That said, the standard way in Java of getting the stack trace skips the exception throwing: StackTraceElement[] st = new Throwable().getStackTrace(). Of course, that would have made them do some actual logging logic, and not just "I dunno, drop the message in the output?"

The only remaining question is how much did this feature cost? Since these were "expert consultants", we can ballpark it as somewhere between "a few thousand dollars" to "many thousands of dollars"..

[Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.