File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA Native Query problem

 
Mohammad wish
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Professionals,
I have a native sql query as the following :

for(init i=0; i <=2 ; i++){
String sql = "Select * from accounts where id = ?";
Query query = em.createNativeQuery(sql,AccountBean.class);
query.setParameter(1, i );

AccountBean accountBean = (AccountBean)query.getSingleResult();
}

for the first loop it works correct but any loop after the first one return the same result to the first one , i debug it, the parameter changed , it works correct if i changed

Query query = em.createNativeQuery(sql,AccountBean.class);

to

Query query = em.createNativeQuery(queryString);

Regards
Wish79
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic