Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Help migrating (JEE6 + jboss + hibernate + jds) resolved(createQuery resolved)
Help migrating (JEE6 + jboss + hibernate + jds) resolved [message #1272081] Sun, 16 March 2014 22:29
johnson russi is currently offline johnson russi
Messages: 1
Registered: March 2014
Junior Member
Beginner in glassfish ...


thanks
Johnson Russi

public List<Empresas> ok_listPermisosEmpresasUsuario(Integer idUsuario ) {
CriteriaBuilder cb = this.em.getCriteriaBuilder();
CriteriaQuery<Empresas> cq = cb.createQuery(Empresas.class);
Root<Empresas> emp = cq.from(Empresas.class);
Join<Empresas, Empresastipostransacciones> tip = emp.join("empresastipostransaccionesCollection" );
Join<Empresastipostransacciones,Permisos> per = tip.join("permisosCollection" );
Join<Permisos,Usuarios> usu = per.join("idusuario" );
cq.select(emp).distinct(true);
Predicate predicate = cb.equal(usu.<Integer> get("idusuario"), idUsuario);
cq.where(predicate);
TypedQuery<Empresas> q = this.em.createQuery(cq);
List<Empresas> listEmp = q.getResultList();
return listEmp;
}

public List<Empresas> listPermisosEmpresasUsuario(Integer idUsuario ) {
String consulta = "SELECT DISTINCT emp FROM Empresas AS emp";
consulta += " JOIN emp.empresastipostransaccionesCollection AS tip";
consulta += " JOIN tip.permisosCollection AS per" ;
consulta += " JOIN per.idusuario AS usu" ;
consulta += " WHERE usu.idusuario = :id";
return this.em.createQuery(consulta,Empresas.class).setParameter("id", idUsuario).getResultList();
}

[Updated on: Tue, 18 March 2014 01:11]

Report message to a moderator

Previous Topic:Cannot insert to 'path' field in Postgres db using EclipseLink
Next Topic:Example of leftJoin?
Goto Forum:
  


Current Time: Wed Jul 23 01:36:19 EDT 2014

Powered by FUDForum. Page generated in 0.25818 seconds