domingo, 10 de octubre de 2010

CriteriaBuider JPA "WHERE" Example

EntityManagerFactory emf = Persistence.createEntityManagerFactory("ExamplePersistence");
EntityManager em = emf.createEntityManager();
CriteriaBuilder cb = em.getCriteriaBuilder();

CriteriaQuery<EntityExample> cqr = cb.createQuery(EntityExample.class);

Root<EntityExample> entityEx= cqr.from(EntityExample.class);

Predicate p1 = cb.equal(entityEx.get(EntityExample_.idEntityExample), 1);
Predicate p2 = cb.equal(entityEx.get(EntityExample_.password), "1234");
       
cqr.where(p1, p2);
       

cqr.select(entityEx);

TypedQuery<EntityExample> tqr = em.createQuery(cqr);
 try{
        EntityExample entEx = tqr.getSingleResult();
        System.out.println("found");
 }
catch(NoResultException nre){
    System.out.println("not found");
}

sábado, 9 de octubre de 2010

Subversion con apache Fedora 13

  • Instalar lo necesario:
          yum -y install httpd subversion trac mod_dav_svn mod_python. 
  • Ir al directorio
          cd /var/www/svn
  • Crear repositorio
           svnadmin create reposvn
  • Dar permisos a apache sobre el repositorio
           chown -R apache.apache reposvn
  • Modificar seguridad del directorio
           chcon -R -t httpd_sys_content_rw_t reposvn
  • Abrir archivo de configuracion
           nano /etc/httpd/conf.d/subversion.conf
  • Agregar repositorio en apache con autenticacion
          <Location /repos>
              DAV svn
              SVNParentPath /var/www/svn
             AuthType Basic
             AuthName "Authorization Realm"
             AuthUserFile /var/svn/passwd
             Require valid-user
          </Location>

  • Agregar usuarios
          htpasswd -m passwd usuario1 (se agrega el parametro "c" la primera vez)
  • Reiniciar Apache
            service httpd restart
  • Probar con la url "http://localhost/repos/reposvn"