I am trying to run native query in a loop, the query displays the correct sql syntax but the output is always the same.
for (int i=0; i<translations.size(); i++) {
Query query = entityManager.createNativeQuery("Select * from " + translations.get(i).getName(), MyModel.class);
rows = (List<MyModel>)query.getResultList();
// rest of the function...
}
now in the console I can see the Hibernate statements like:
Hibernate: Select * from translation1
Hibernate: Select * from translation2
Hibernate: Select * from translation3
but the variable "rows" always contains the result of the first select statement i.e. rows of translation1 table.
Any ideas why in the console it shows that it is selecting from other tables too but in reality it always gets data from translation1 table?
rowsis used. For example, why isn'trowsdeclared within the for loop?