Code example for SessionFactory

Methods: openSession

0
 
  /** Stores the given mock entity. 
   * @param entity the entity to store. 
   */ 
  public void save(final MockEntity entity) {
    Session session = sessionFactory.openSession();
    Transaction tx = session.beginTransaction();
    session.saveOrUpdate(entity);
    tx.commit();
    session.flush();
  } 
 
  /** Search mock entities given by its name. 
   * @param name the name to search. 
   * @return a list of mock entities. 
   */ 
  @SuppressWarnings("unchecked") 
  public List<MockEntity> searchLikeName(final String name) {
    FullTextSession fullTextSession = TestUtil.fullTextSession();
    WildcardQuery wilCardQuery = new WildcardQuery(new Term("name",