This is in my DAO:
public List<Weather> getCurrentWeather() { return sessionFactory.getCurrentSession().createQuery("from Weather").list(); }
This gets all the elements from the Weather table. But let me say that I want to do something like this (I want only one element from the Weather table):
public Weather getCurrentWeather() { return sessionFactory.getCurrentSession().createQuery("from Weather where id = 1").list(); // here should be something else than list() }
I know that in the end there should not be list() , but what should I write there to get only one object?
java spring hibernate sessionfactory
Jaanus
source share