I can confirm that this is still a bug in 5.1. Duplicate of HHH-2536 - NPE with custom SQL query and formula property Complete .
See also https://issues.jboss.org/browse/JBPAPP-6571.