Skip to content

Commit

Permalink
#3614, filter param for basic query
Browse files Browse the repository at this point in the history
  • Loading branch information
raprasad committed Jun 1, 2017
1 parent 4df733c commit 92701e3
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/main/java/edu/harvard/iq/dataverse/UserServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,27 +161,26 @@ public List<Object[]> getUserList(String searchKey, String sortKey, Integer resu
searchKey = "";
}


System.out.println("Search key: " + searchKey);

String qstr = "SELECT u.id, u.useridentifier,";
qstr += " u.lastname, u.firstname, u.email,";
qstr += " u.affiliation, u.superuser,";
qstr += " u.position, u.modificationtime";
qstr += " FROM authenticateduser u";
/*qstr += " WHERE u.useridentifier ILIKE ':searchKey%'";
qstr += " OR u.firstname ILIKE ':searchKey%'";
qstr += " OR u.lastname ILIKE ':searchKey%'";*/
qstr += " WHERE u.useridentifier ILIKE #searchKey";
qstr += " OR u.firstname ILIKE #searchKey";
qstr += " OR u.lastname ILIKE #searchKey";
//qstr += " WHERE u.useridentifier = #searchKey";

qstr += " ORDER BY u.useridentifier";
qstr += " LIMIT " + resultLimit;

System.out.println("--------------\n\n" + qstr);

Query nativeQuery = em.createNativeQuery(qstr);
//nativeQuery.setParameter("searchKey", searchKey);
//nativeQuery.setParameter(2, searchKey);
//nativeQuery.setParameter(3, searchKey);
//nativeQuery.setParameter(4, sortKey);

System.out.println("--------------\n\n" + nativeQuery.toString());
nativeQuery.setParameter("searchKey", searchKey + "%");


return nativeQuery.getResultList();
Expand Down

0 comments on commit 92701e3

Please sign in to comment.