Package ru.portnyagin.helpdeskru.service

Source Code of ru.portnyagin.helpdeskru.service.FileHDService

/**
*
* @author ilya portnyagin iportnyagin@gmail.com
*/

package ru.portnyagin.helpdeskru.service;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import ru.portnyagin.helpdeskru.model.FileHD;
import ru.portnyagin.helpdeskru.model.FileHD_;
import ru.portnyagin.helpdeskru.model.Request;

@Stateless
public class FileHDService extends AbstractService<FileHD> {
    @PersistenceContext(unitName = "HelpDeskRuPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public FileHDService() {
        super(FileHD.class);
    }
   
    public List<FileHD> findByRequest(Request request) {
       
        CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
        CriteriaQuery cq = cb.createQuery();
        Root<FileHD> z = cq.from(FileHD.class);
        cq.where(cb.equal(z.get(FileHD_.request), request));
        cq.select(z);
        return getEntityManager().createQuery(cq).getResultList();
       
    }
   
   
   
}
TOP

Related Classes of ru.portnyagin.helpdeskru.service.FileHDService

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.