我有一个列表<object [] =“”>返回null结果

时间:2018-01-03 11:53:28

标签: spring hibernate collections

public List findPostByName(Long [] Poste,String Nom)抛出ServiceException {         列表resultat = null;

    try {
        resultat =  this.entityManager.createNativeQuery
            (
            "SELECT "
            + "id, "
            + " non, "
            + " prenom, "
            + " direction, "
            + " emplacement "
            + "FROM intervention "
            + "WHERE Post= :Post"
            + "AND Nom= :Nom"
            )
            .setParameter("Post", Arrays.asList(Post))
            .setParameter("Nom", Nom)
            .getResultList();
        log.info("=============GETRESULTAT========>>>"+resultat);

    }catch(Exception e){
    System.err.println(e.getMessage());
    }
    return resultat ;
}

1 个答案:

答案 0 :(得分:0)

必须有一些异常,您需要记录堆栈跟踪然后解决问题。 Query.getResultList()永远不会给你空列表。您可以通过触发以下查询然后添加参数来调试问题:

    "SELECT "
        + "id, "
        + " non, "
        + " prenom, "
        + " direction, "
        + " emplacement "
        + "FROM intervention "