Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

refresh collection of objects in hibernate

 
Rashid Darvesh
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
i have some very rough going with hibernate.
i have a collection of Test Objects which i retrieve using hiberante.Works fine no problem. Later i ask user to insert new Test. Because of some problem adn some complex programming, i am using normal jdbc programming (like connection, statement.execute) to insert the new Test. now i when i again use hibernate to fetch test i am unable to find the new Test object in the list which was inserted using conventioanl jdbc. i have to restart Tomcat again to get that new Test object appear in the list. i understand that the test were created not using hiberante but with conventional jdbc but is there a way i can refresh session to get the new test. Now i know there is session.refresh(obj) but plese note i cant call that since i am returning a list of Test objects. i think i am clear in explaining this. Any help.

Thanks
Rashid
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
now i when i again use hibernate to fetch test


Which API of Hibernate do you use to do that? Can you post that part of your code?
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried session.refresh()?
 
Rashid Darvesh
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Gilbert.
i could try session.refresh on a single object but not on the list of objects. the thing is i have test type combo box and if i retrieve it in hiberante as a list of testtype objects. now when i add another test type in databse manually thru SQL, hibernate doesn't refresh it. i could run a session.refresh(obj) on a particular object but in my case i have a list of testtyep objects. hope this is clear. what is hte best way to refresh the list of testType.
The other question is teh session factory only created once for the lifespan of the browser. i did a debug on my code and only the first time the sessionfacotry is instantiated and teh session is created from the sessionfacotry. later on its only the sesion which is created and closed.
Please let me know the answers.
Much appreicated
Thansk
Rashid
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic