Java Tutorial/Hibernate/Cache
Turn off Cache Through Config File
File: Main.java
import org.hibernate.Session;
public class Main {
public static void main(String[] args) throws Exception {
HibernateUtil hibernateUtil = new HibernateUtil();
hibernateUtil.executeSQLCommand("create table survey (id int,name varchar);");
Session session = hibernateUtil.getSession();
Survey survey = new Survey();
survey.setName("Survey");
System.out.println(survey.getId());
session.save(survey);
session.flush();
System.out.println(survey.getId());
Survey surveyInSession = (Survey) session.get(Survey.class, survey.getId());
System.out.println(surveyInSession.getName());
session.close();
hibernateUtil.checkData("select * from survey");
}
}