KazankovMarch

getBySubString

Apr 23rd, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1.     public <T extends AbstractDictionaryN> List<T> getLikeThis(Class type, String subString) {
  2.         try {
  3.             String jpql = "select d from " + type.getCanonicalName() + " d where d.name like :sub";
  4.             return entityManager.createQuery(jpql)
  5. //                    .setParameter("table", type.getCanonicalName())
  6.                     .setParameter("sub", "%" + subString + "%")
  7.                     .getResultList();
  8.         } catch (QueryException | ClassCastException e) {
  9.             e.printStackTrace();
  10.             return new ArrayList<>();
  11.         }
  12.     }
Advertisement
Add Comment
Please, Sign In to add comment