Example usage for org.springframework.transaction.annotation Propagation MANDATORY

List of usage examples for org.springframework.transaction.annotation Propagation MANDATORY

Introduction

In this page you can find the example usage for org.springframework.transaction.annotation Propagation MANDATORY.

Prototype

Propagation MANDATORY

To view the source code for org.springframework.transaction.annotation Propagation MANDATORY.

Click Source Link

Document

Support a current transaction, throw an exception if none exists.

Usage

From source file:se.vgregion.urlservice.repository.jpa.JpaUserRepository.java

@Override
@Transactional(propagation = Propagation.MANDATORY, readOnly = true)
public Owner findByName(String name) {
    try {//  ww  w. j ava  2  s  .c o m
        return (Owner) entityManager
                .createQuery("select l from " + type.getSimpleName() + " l where l.name = :name")
                .setParameter("name", name).getSingleResult();
    } catch (NoResultException e) {
        return null;
    }
}

From source file:se.vgregion.urlservice.repository.jpa.JpaRedirectRuleRepository.java

/**
 * Find link by domain and pattern.//from   w w  w  .  j  a  v  a  2 s  .co m
 */
@SuppressWarnings("unchecked")
@Transactional(propagation = Propagation.MANDATORY, readOnly = true)
public RedirectRule findByDomainAndPattern(String domain, String pattern) {
    try {
        return (RedirectRule) entityManager
                .createQuery("select l from " + type.getName()
                        + " l where l.domain = :domain and l.pattern = :pattern")
                .setParameter("domain", domain).setParameter("pattern", pattern).getSingleResult();
    } catch (NoResultException e) {
        return null;
    }

}

From source file:com.lewischooman.dao.IMovieShowDAO.java

@Transactional(value = "txManager", propagation = Propagation.MANDATORY)
Status updateMovieShowWithBooking(MovieShowDB[] movieShowArr, Integer seatsBooked);

From source file:dk.nsi.minlog.ws.dao.ebean.LogEntryDaoEBean.java

@Override
@Transactional(propagation = Propagation.MANDATORY)
public List<LogEntry> findByCPRAndDates(String cpr, DateTime from, DateTime to) {
    ExpressionList<LogEntry> query = query().where().eq("cprNrBorger", cpr);
    if (from != null) {
        query = query.ge("tidspunkt", from);
    }/*from  w w  w  .  ja  v a 2s .  c  om*/

    if (to != null) {
        query.le("tidspunkt", to);
    }
    return query.findList();
}

From source file:com.oak_yoga_studio.dao.impl.CustomerDAOImpl.java

@Transactional(propagation = Propagation.MANDATORY)
@Override//  ww  w .  j  a v a  2  s  . co  m
public List<Waiver> getApprovedWaiversByCustomerID(int customerID) {

    List<Waiver> waivers;

    Query query = sf.getCurrentSession().createQuery("from Waiver where customer.id=:customerID");

    query.setParameter("customerID", customerID);
    waivers = query.list();

    return waivers;

}

From source file:com.devicehive.dao.rdbms.RdbmsGenericDao.java

@Transactional(propagation = Propagation.MANDATORY)
public <T extends Serializable> T merge(T entity) {
    return em.merge(entity);
}

From source file:net.dontdrinkandroot.persistence.dao.TypedJpaDao.java

@Override
@Transactional(propagation = Propagation.MANDATORY)
public void delete(final E entity) {
    super.delete(entity, this.entityClass);
}

From source file:se.vgregion.urlservice.repository.jpa.JpaApplicationRepository.java

@Override
@Transactional(propagation = Propagation.MANDATORY, readOnly = true)
public Application findByName(String name) {
    try {/*from www  .  j a  v  a 2s  . co  m*/
        return (Application) entityManager
                .createQuery("select l from " + type.getSimpleName() + " l where l.name = :name")
                .setParameter("name", name).getSingleResult();
    } catch (NoResultException e) {
        return null;
    }
}

From source file:se.vgregion.urlservice.repository.jpa.JpaBookmarkRepository.java

@Override
@Transactional(propagation = Propagation.MANDATORY, readOnly = true)
public Bookmark findByHash(String hash, Owner owner) {
    try {//from   w  ww . ja v  a  2s .co  m
        // TODO could have multiple matches, handle
        String query = "select l from " + type.getSimpleName()
                + " l where l.hash = :hash and l.owner.id = :owner";

        return (Bookmark) entityManager.createQuery(query).setParameter("hash", hash)
                .setParameter("owner", owner.getId()).getSingleResult();

    } catch (NoResultException e) {
        return null;
    }

}

From source file:com.oak_yoga_studio.dao.impl.ShoppingCartItemDAOImpl.java

@Transactional(propagation = Propagation.MANDATORY)
@Override/*from  w  ww  .  ja v a2 s  .c o m*/
public List<ShoppingCartItem> getShoppingCartItemsOfCart(ShoppingCart cart) {
    List<ShoppingCartItem> items;
    Query q = sf.getCurrentSession()
            .createQuery("Select item from ShoppingCartItem item where item.shoppingCart=cart");
    items = q.list();
    return items;
}