• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

I want to use List<String> in JPQL syntaxis

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.
Can I use List<CardIds> in JPQL syntaxsis? I can, please write.
Thanks

public int getCardsByIdsSorted(//List<String> cardIds,
String field, boolean ascending) {
int a = 0;
List<Card> cardList; //= new ArrayList<Card>();
List<String> cardIds = new ArrayList<String>();
cardIds.add("66b72972-ea0e-4b24-a692-f220da739298");
cardIds.add("35676406-0fd4-4fd2-9ca7-22c628978983");
cardIds.add("520602e3-bd47-486c-8824-b2ac7d4957ab");
try {
cardList = entityManager.createQuery("SELECT t FROM Card t WHERE t.id IN (:cardIds)").setParameter("cardIds", cardIds).getResultList();
a = cardList.size();
} catch (Exception ex) {
System.out.println(ex.getMessage());
}

return a;
}
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can try the following:



Next time...could you put your code inside "Code" tags?...
it would make it more readable ;)

Regards
Dave
 
Rufat Babakishiyev
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for attention
cardList = entityManager.createQuery("SELECT t FROM Card t WHERE t.id IN (:cardIds)").setParameterList("cardIds", cardIds).getResultList();

When I tried that , I can't find setParamaterList() method .
 
Davide Crudo
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, my bad. The setParameterList seems not to be available in the EntityManager,
you could use hibernate in your Bean:

The setParameterList is available, but in the Hibernate Query (instead of the javax.Persistence package).

You would then need to get the SessionFactory injected and retrieve the hibernate session:

 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic