Updating session in hibernate -


After

Then to get the number of rows from my database in a list I'm using Hibernate:

< Pre> public class FlightDAOImpl applies FlightDAO {Private session session = HibernateUtil.getSessionFactory () openSession () .; @SuppressWarnings ("uncontrolled") @Override from public list & lt; Flight & gt; ListFlight () {List & lt; Flight & gt; List = New Arrestist & lt; & Gt; (); Session.beginTransaction (); List = session.createQuery ("Flight_Origin = Flight: flight_id or Flight_Destination =: destination_id") .setParameter ("origin_id", App.airport.getAirportId ()) .setParameter ("destination_id", App.airport.getAirportId () ) .list (); Committed to session.getTransaction (). Return list; }}

This works, but I will not update the session updating some data in the table (by the SQL developer way) I will get the same data the next time I get the listFlight phone ( ). I can use this instead:

  from public list & lt; Flight & gt; ListFlight () {List & lt; Flight & gt; List = New Arrestist & lt; & Gt; (); Session s = HibernateUtil.getSessionFactory (). OpenSession (); S.beginTransaction (); List = s.createQuery ("Flight from Flight_Augin =: original_id or flight_destin =: destination_id") .setParameter ("origin_id", app.airport.getAirportId ()) .setParameter ("destination_id", app.airport.getAirportId () ) .list (); Committed to s.getTransaction (). S.close (); Return list; }  

But it will require me to close the session and open the call list (fly) every time. Is there a way to update the data for the entire session and to reopen it? I am a newbie, so any advice would be appreciated.

Use getCurrentSession () instead of openSession ().


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -