Example usage for javax.persistence EntityManager createQuery

List of usage examples for javax.persistence EntityManager createQuery

Introduction

In this page you can find the example usage for javax.persistence EntityManager createQuery.

Prototype

public Query createQuery(CriteriaDelete deleteQuery);

Source Link

Document

Create an instance of Query for executing a criteria delete query.

Usage

From source file:gr.upatras.ece.nam.baker.impl.BakerJpaController.java

public BakerUser readBakerUserByUsername(String username) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    Query q = entityManager.createQuery("SELECT m FROM BakerUser m WHERE m.username='" + username + "'");
    return (q.getResultList().size() == 0) ? null : (BakerUser) q.getSingleResult();
}

From source file:gr.upatras.ece.nam.baker.impl.BakerJpaController.java

public BakerUser readBakerUserBySessionID(String id) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    Query q = entityManager.createQuery("SELECT m FROM BakerUser m WHERE m.currentSessionID='" + id + "'");
    return (q.getResultList().size() == 0) ? null : (BakerUser) q.getSingleResult();
}

From source file:gr.upatras.ece.nam.baker.impl.BakerJpaController.java

public BakerUser readBakerUserByEmail(String email) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    Query q = entityManager.createQuery("SELECT m FROM BakerUser m WHERE m.email='" + email + "'");
    return (q.getResultList().size() == 0) ? null : (BakerUser) q.getSingleResult();
}

From source file:com.jada.admin.site.SiteLoader.java

public void loadCreditCard() throws Exception {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    String sql = "from CreditCard where siteId = :siteId order by creditCardId";
    Query query = em.createQuery(sql);
    query.setParameter("siteId", Constants.SITE_SYSTEM);
    Iterator<?> iterator = query.getResultList().iterator();
    while (iterator.hasNext()) {
        CreditCard master = (CreditCard) iterator.next();
        CreditCard creditCard = new CreditCard();
        PropertyUtils.copyProperties(creditCard, master);
        creditCard.setSite(site);/*from  www  .  j ava 2 s. c  om*/
        creditCard.setCreditCardId(null);
        creditCard.setRecUpdateBy(userId);
        creditCard.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        creditCard.setRecCreateBy(userId);
        creditCard.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        em.persist(creditCard);
    }
}

From source file:gr.upatras.ece.nam.baker.impl.BakerJpaController.java

public InstalledBun readInstalledBunByName(final String name) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();

    Query q = entityManager.createQuery("SELECT m FROM InstalledBun m WHERE m.name='" + name + "'");
    return (q.getResultList().size() == 0) ? null : (InstalledBun) q.getSingleResult();
}

From source file:gr.upatras.ece.nam.baker.impl.BakerJpaController.java

public InstalledBun readInstalledBunByUUID(final String uuid) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();

    Query q = entityManager.createQuery("SELECT m FROM InstalledBun m WHERE m.uuid='" + uuid + "'");
    return (q.getResultList().size() == 0) ? null : (InstalledBun) q.getSingleResult();
}

From source file:gr.upatras.ece.nam.baker.impl.BakerJpaController.java

public long countUsers() {

    EntityManager entityManager = entityManagerFactory.createEntityManager();

    Query q = entityManager.createQuery("SELECT COUNT(s) FROM BakerUser s");
    return (Long) q.getSingleResult();
}

From source file:gr.upatras.ece.nam.baker.impl.BakerJpaController.java

public long countSubscribedResources() {

    EntityManager entityManager = entityManagerFactory.createEntityManager();

    Query q = entityManager.createQuery("SELECT COUNT(s) FROM SubscribedResource s");
    return (Long) q.getSingleResult();
}

From source file:gr.upatras.ece.nam.baker.impl.BakerJpaController.java

public BakerProperty readPropertyByName(String name) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();

    Query q = entityManager.createQuery("SELECT m FROM BakerProperty m WHERE m.name='" + name + "'");
    return (q.getResultList().size() == 0) ? null : (BakerProperty) q.getSingleResult();

}

From source file:gr.upatras.ece.nam.baker.impl.BakerJpaController.java

public SubscribedResource readSubscribedResourceByuuid(String uuid) {

    EntityManager entityManager = entityManagerFactory.createEntityManager();

    Query q = entityManager.createQuery("SELECT m FROM SubscribedResource m WHERE m.uuid='" + uuid + "'");
    return (q.getResultList().size() == 0) ? null : (SubscribedResource) q.getSingleResult();

}