P E N C I L
Login
Hibernate SessionFactory
  1. MAIN DOCS:
    http://docs.jboss.org/hibernate/orm/5.0/userguide/html_single/Hibernate_User_Guide.html
    https://docs.jboss.org/hibernate/orm/3.3/reference/en/html/querycriteria.html
  2. Dao is any java class which refer to SessionFactory.
    Whenever accessing to database, just call sessionFactory.getCurrentSession()
    session = this.sessionFactory.getCurrentSession();
    session.createQuery("from EmployeeEntity").list();
  3. Get & Load
    1. session.get(key, LockMode.READ) => return null if absent
    2. session.load(key) => throw error if absent
  4. Save & Delete
    1. session.delete(obj)  // obj must be a loaded object or a fake object but id exist
    2. session.save(obj)
  5. Debug
    1. How to find out server name?
      1. this.sessionFactory.getCurrentSession().connection().getMetaData().getURL()
      2. How to find connection properties? settings > datasourceToUse > targetDatasource > connectionProperties
  6. ​Trouble shoot
    1. ​Why query no result?
      The entity class is not in hibernate-mapping. There is no error, just no result.
    2. Ho