It's not a secret anymore!
The moose likes EJB and other Java EE Technologies and the fly likes JPA Native Query problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JPA Native Query problem" Watch "JPA Native Query problem" New topic

JPA Native Query problem

Mohammad wish

Joined: Oct 11, 2011
Posts: 12
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);


Query query = em.createNativeQuery(queryString);

I agree. Here's the link:
subject: JPA Native Query problem
It's not a secret anymore!