• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB3 -JPA -Dynamic SQL

 
Cloey Tan
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Im working on a project which requires me to write codes using ejb3 JPA, to generate queries dynamically to retrieve data from table, and join the appropriate tables dynamically as well. I wonder how can that be done, are there any useful examples? if use the annotation, it wouldt be that flexibe enough right?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cloey,
See this example of passing the query as a string. The article happens to be from Oracle, but it's not an Oracle specific example.

I'm going to move this to our JPA/ORM forum for you.
 
Cloey Tan
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the link, was just wondering, as for dynamic sql, entityManager.createQuery and createNativeQuery, when to use those 2. And seems like native query is much more flexible, as i can construct the whole sql statement, then only execute it?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic