Code example for Session

Methods: flushsavecreateQuery

0
        if (vt == null) return 1;
        else return vt.getVersion() + 1;
    } 
 
    public void setVersion(long version) {
        _session.flush();
        VersionTrackerDAOImpl vt = (VersionTrackerDAOImpl)
                _session.createQuery("from VersionTrackerDAOImpl v ").uniqueResult();
        if (vt == null) {
            vt = new VersionTrackerDAOImpl();
            vt.setId(1);
        } 
        vt.setVersion(version);
        _session.save(vt);
    } 
 
    @SuppressWarnings("unchecked") 
    public Collection<DeploymentUnitDAO> getDeploymentUnits() {
        Criteria c = _session.createCriteria(DeploymentUnitDaoImpl.class);
        return c.list();