JPA: Using POJOs in SQL Queries Result Mapping Simplyfied

Because there is no Constructor Expression for native SQL queries in JPA I wrote a simple SqlResultMapper. The result mapper is inspired by EclipseLink and Hibernate:

In contrast to these two vendor specific implementations my JpaSqlResultMapper works with every JPA implementation.
There are two important remarks:
  1. Constructor must have the same number of arguments as the result of the SQL query
  2. The result types must match
Your comment is highly appreciated!

public class JpaSqlResultMapper {

public static List list(Query q, Class clazz)
throws IllegalArgumentException {

Constructor ctor =
(Constructor) clazz.getDeclaredConstructors()[0];
List result = new ArrayList();

List list = q.getResultList();
    for (Object obj : list) {
if (ctor.getParameterTypes().length == 1) {
obj = new Object[] { obj };
createAndAddBean(ctor, (Object[]) obj, result);
return result;

private static void createAndAddBean(
Constructor ctor, Object[] args, List result) {
try {
T obj = (T) ctor.newInstance(args);
} catch (Exception e) {
throw new RuntimeException(e);