aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Native query always returning same data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Native query always returning same data" Watch "Native query always returning same data" New topic
Author

Native query always returning same data

Dimitris Karageorgopoulos
Greenhorn

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


Vladimir Galcenco
Greenhorn

Joined: Mar 23, 2011
Posts: 4
Could you post the loop as well? I'd like to see when and how your job id changes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Native query always returning same data