• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Native query always returning same data

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,

I have a native query defined in an EJB entity bean of the sort SELECT * FROM EMPLOYEES WHERE JOB_ID = <variable>

I execute the query within a for loop sequentially for a different job id.
I get the results using the getResultList function .
My problem is that the list of results for all executions of the query are the same and correspond to the first job id of the loop.
Presumambly some sort of caching takes place and I don;t know how to turn it off.

Can anybody help?
This is an exerpt of my code:

Query query = em.createNativeQuery("SELECT * FROM EMPLOYEES" +
" WHERE JOB_ID="+jobId,Employeeclass);
List<Employee> empList = (List<Employee>)query.getResultList();


 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you post the loop as well? I'd like to see when and how your job id changes.
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic