Code example for SessionFactory

Methods: getCurrentSession

0
    } 
    @Override 
    public Entity findById(PrimaryKey id) throws Exception {
        log.debug("getting instance with id: " + String.valueOf(id));
        if (id != null) {
            return (Entity)this.sessionFactory.getCurrentSession().get(getPersistentClass(), id);
        } 
        return null; 
    } 
 
    @Override 
    public List<Entity> getAll() throws Exception {
        log.debug("getting all data from table: "+getPersistentClass().getName());
        Query qry = sessionFactory.getCurrentSession().createQuery("from "+ getPersistentClass().getName() +" log");
        return (List<Entity>)qry.list();
    } 
 
    @Override 
    @Transactional 
    public Entity add(Entity instance) throws Exception {
Experience pair programming with AI  Get Codota for Java