aspose file tools*
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
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JPA Native Query problem" Watch "JPA Native Query problem" New topic
Author

JPA Native Query problem

Mohammad wish
Greenhorn

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);

to

Query query = em.createNativeQuery(queryString);

Regards
Wish79
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPA Native Query problem