Example usage for javax.persistence FlushModeType COMMIT

List of usage examples for javax.persistence FlushModeType COMMIT

Introduction

In this page you can find the example usage for javax.persistence FlushModeType COMMIT.

Prototype

FlushModeType COMMIT

To view the source code for javax.persistence FlushModeType COMMIT.

Click Source Link

Document

Flushing to occur at transaction commit.

Usage

From source file:net.groupbuy.dao.impl.LogDaoImpl.java

public void removeAll() {
    String jpql = "delete from Log log";
    entityManager.createQuery(jpql).setFlushMode(FlushModeType.COMMIT).executeUpdate();
}

From source file:net.groupbuy.dao.impl.CartDaoImpl.java

public void evictExpired() {
    String jpql = "delete from Cart cart where cart.modifyDate <= :expire";
    entityManager.createQuery(jpql).setFlushMode(FlushModeType.COMMIT)
            .setParameter("expire", DateUtils.addSeconds(new Date(), -Cart.TIMEOUT)).executeUpdate();
}

From source file:net.groupbuy.dao.impl.AreaDaoImpl.java

public List<Area> findRoots(Integer count) {
    String jpql = "select area from Area area where area.parent is null order by area.order asc";
    TypedQuery<Area> query = entityManager.createQuery(jpql, Area.class).setFlushMode(FlushModeType.COMMIT);
    if (count != null) {
        query.setMaxResults(count);// w  w  w.j  av a  2 s  . co m
    }
    return query.getResultList();
}

From source file:net.groupbuy.dao.impl.SeoDaoImpl.java

public Seo find(Type type) {
    if (type == null) {
        return null;
    }//from   ww  w.  ja v  a2  s.c  om
    try {
        String jpql = "select seo from Seo seo where seo.type = :type";
        return entityManager.createQuery(jpql, Seo.class).setFlushMode(FlushModeType.COMMIT)
                .setParameter("type", type).getSingleResult();
    } catch (NoResultException e) {
        return null;
    }
}

From source file:net.groupbuy.dao.impl.PaymentDaoImpl.java

public Payment findBySn(String sn) {
    if (sn == null) {
        return null;
    }/*from  w w w .j  av  a 2  s .co m*/
    String jpql = "select payment from Payment payment where lower(payment.sn) = lower(:sn)";
    try {
        return entityManager.createQuery(jpql, Payment.class).setFlushMode(FlushModeType.COMMIT)
                .setParameter("sn", sn).getSingleResult();
    } catch (NoResultException e) {
        return null;
    }
}

From source file:net.groupbuy.dao.impl.AdminDaoImpl.java

public boolean usernameExists(String username) {
    if (username == null) {
        return false;
    }//  www .j  a v  a2 s.  co m
    String jpql = "select count(*) from Admin admin where lower(admin.username) = lower(:username)";
    Long count = entityManager.createQuery(jpql, Long.class).setFlushMode(FlushModeType.COMMIT)
            .setParameter("username", username).getSingleResult();
    return count > 0;
}

From source file:net.groupbuy.dao.impl.ShippingDaoImpl.java

public Shipping findBySn(String sn) {
    if (sn == null) {
        return null;
    }/*ww w  .j av  a 2 s .  co  m*/
    String jpql = "select shipping from Shipping shipping where lower(shipping.sn) = lower(:sn)";
    try {
        return entityManager.createQuery(jpql, Shipping.class).setFlushMode(FlushModeType.COMMIT)
                .setParameter("sn", sn).getSingleResult();
    } catch (NoResultException e) {
        return null;
    }
}

From source file:net.groupbuy.dao.impl.PluginConfigDaoImpl.java

public boolean pluginIdExists(String pluginId) {
    if (pluginId == null) {
        return false;
    }//from   ww  w. jav  a  2 s  . com
    String jpql = "select count(*) from PluginConfig pluginConfig where pluginConfig.pluginId = :pluginId";
    Long count = entityManager.createQuery(jpql, Long.class).setFlushMode(FlushModeType.COMMIT)
            .setParameter("pluginId", pluginId).getSingleResult();
    return count > 0;
}

From source file:net.groupbuy.dao.impl.DeliveryCenterDaoImpl.java

public DeliveryCenter findDefault() {
    try {/*from w ww  . jav  a  2  s .c  o m*/
        String jpql = "select deliveryCenter from DeliveryCenter deliveryCenter where deliveryCenter.isDefault = true";
        return entityManager.createQuery(jpql, DeliveryCenter.class).setFlushMode(FlushModeType.COMMIT)
                .getSingleResult();
    } catch (NoResultException e) {
        return null;
    }
}

From source file:net.groupbuy.dao.impl.DeliveryTemplateDaoImpl.java

public DeliveryTemplate findDefault() {
    try {/* ww  w. j  av  a  2  s . c  o m*/
        String jpql = "select deliveryTemplate from DeliveryTemplate deliveryTemplate where deliveryTemplate.isDefault = true";
        return entityManager.createQuery(jpql, DeliveryTemplate.class).setFlushMode(FlushModeType.COMMIT)
                .getSingleResult();
    } catch (NoResultException e) {
        return null;
    }
}