0

i'm having troubles with geting my tables to synchronize with a database. The main table in my application represents a mysql database view of two tables joined, and its bound to a result list of a JPA query over that view's entity class. The problem is, when i update some data in my database table, and then repeat calling of myQuery.getResultList, the list of results returned is the same as the one returned before updating that table. So i guess the problem is that the SELECT statement inside my SQL view isn't getting executed every time i query the JPA entity.

here's an example of the code

enManager.getTransaction().begin();
Myentity s = enManager.find(Myentity.class, selected.getMsId());
s.setKom(k);
enManager.getTransaction().commit();

resultList.clear();
resultList.addAll(myQuery.getResultList());

and the resultList stays the same as the one before performing an update. Is there a workaround, or should I start my application from scratch?

Stevi Deter
  • 1,523
  • 9
  • 15
Kani
  • 53
  • 3
  • Where/how is the update occurring? – Stevi Deter May 26 '11 at 22:14
  • well, the update is not much different from the example code shown above, its a part of actionperformed method triggered when a button is clicked, confirming value entered in a JTextField, so im not editing database directly by editing jTable cell content, neither is this one of those problems related to a table not updating, what i'm talking about is a result list not being updated, even when i repeat getResultList(). I see that a table in a database is being updated correctly every time i perform this, but querying a view doesn't reflect changes made to the actual tables. – Kani May 26 '11 at 23:08
  • Without seeing your code, I think this article might provide some useful information, specifically the accepted answer: http://stackoverflow.com/questions/2400430/invalidating-jpa-entitymanager-session – Stevi Deter May 26 '11 at 23:55
  • Oh yes! Thanks a lot for this...not exactly a solution to my problem since i used Eclipselink, not Hibernate, but following your trail, i found this http://stackoverflow.com/questions/2809275/disable-caching-in-jpa-eclipselink – Kani May 27 '11 at 02:19

1 Answers1

0

How your entity looks like, and what are their cascade type? and what is k? If k is another entity then how k looks like?

Jahid
  • 66
  • 1
  • 2
  • 4