I came across this example from a book while learning about the Hibernate framework.
public class BasicMovieManager()
{
private void persistMovie(Movie movie)
{
Session session=sessionFactory.getCurrentSession();
session.beginTransaction();
session.save(movie);
session.getTransaction().commit();
}
}
I can understand that the Movie object has to be mapped and written to the database. I also understand that the commit step will write to the database. But what is the purpose of save() here? A few sources I referred say that save() persists the data. Doesn't persist mean writing to a permanent storage? If not,what exactly does it mean?
save()step?save()fails, then the database will not be committed.. It will throw an exception.. And yes.. you should catch the exception..