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

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

Introduction

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

Prototype

Propagation SUPPORTS

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

Click Source Link

Document

Support a current transaction, execute non-transactionally if none exists.

Usage

From source file:org.jrecruiter.service.impl.FlexServiceImpl.java

@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public Job getJob(Long jobId) {
    return jobDao.get(jobId);
}

From source file:com.czecht.architecture.ddd.annotations.support.infrastructure.repository.jpa.GenericJpaRepository.java

@Transactional(propagation = Propagation.SUPPORTS)
public A load(AggregateId id) {
    //lock to be sure when creating other objects based on values of this aggregate
    A aggregate = entityManager.find(clazz, id, LockModeType.OPTIMISTIC);

    if (aggregate == null)
        throw new RuntimeException("Aggregate " + clazz.getCanonicalName() + " id = " + id + " does not exist");

    if (aggregate.isRemoved())
        throw new RuntimeException("Aggragate + " + id + " is removed.");

    spring.autowireBean(aggregate);//from ww  w.j a  v  a2 s  . c  om

    return aggregate;
}

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

/**
 * //  w  ww .j  av a 2  s.  c  om
 * @returns only faculty users
 */
@Transactional(propagation = Propagation.SUPPORTS)
@Override
public List<Faculty> getAllFaculties() {
    List<Faculty> faculties;
    Query query = sf.getCurrentSession().createQuery("from Faculty");
    faculties = query.list();

    return faculties;
}

From source file:de.crowdcode.bitemporal.example.AddressServiceImpl.java

@Override
@Transactional(propagation = Propagation.SUPPORTS)
public Integer getAmountOfAddress() {
    Integer amount = addressRepository.getAmount();
    return amount;
}

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

@Transactional(propagation = Propagation.SUPPORTS)
@Override/*from  w ww. ja v  a 2 s .c  o m*/
public List<Enrollment> getAllEnrollments() {

    List<Enrollment> enrollments;

    Query query = sf.getCurrentSession().createQuery("from Enrollment");
    enrollments = query.list();

    return enrollments;

}

From source file:com.inkubator.sms.gateway.service.impl.UserDetailsServiceImpl.java

@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED, timeout = 30)
public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException, DataAccessException {
    System.out.println("user detail service");
    if (userName == null || userName.trim().isEmpty()) {
        throw new UsernameNotFoundException("Empty username");
    }//from w  w w.j av a  2s.co  m

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Security verification for user '" + userName + "'");
    }
    SmsGatewayUser spiUser = this.userDao.getByUserIdOrEmail(userName);
    if (spiUser == null) {
        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("User " + userName + " could not be found");
        }
        throw new UsernameNotFoundException("user " + userName + " could not be found");
    } else {
        System.out.println("ketemu kokk");
    }
    //        List<SpiRole> spiRoles = new ArrayList<>();
    List<String> dataRole = new ArrayList<>();
    for (UserRole spiUserRole : userRoleDao.getByUserId(spiUser.getId())) {
        //            spiRoles.add(spiUserRole.getSpiRole());
        dataRole.add(spiUserRole.getRole().getRoleName());
    }
    Collection<GrantedAuthority> grantedAuthorities = toGrantedAuthorities(dataRole);
    String password = spiUser.getPassword();
    Boolean isActive = Boolean.FALSE;
    Boolean isLock = Boolean.FALSE;
    Boolean isExired = Boolean.FALSE;

    if (spiUser.getIsActive() == 1) {
        isActive = Boolean.TRUE;
    }
    if (spiUser.getIsExpired() == 1) {
        isExired = Boolean.TRUE;
    }
    if (spiUser.getIsLock() == 1) {
        isLock = Boolean.TRUE;
    }
    //        for (SpiRole spiRole : spiRoles) {
    //            dataRole.add(spiRole.getRoleName());
    //        }
    return new User(userName, password, isActive, true, !isExired, !isLock, grantedAuthorities);
}

From source file:com.brienwheeler.svc.users.impl.UserEmailAddressDao.java

@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public UserEmailAddress findByEmailAddress(EmailAddress emailAddress) {
    Query query = entityManager.createQuery("from UserEmailAddress where emailAddress.address = :address");
    query.setParameter("address", emailAddress.getAddress());
    return getSingleResultOrNull(query);
}

From source file:com.brienwheeler.lib.db.dao.PersistentAttributeDaoBase.java

@SuppressWarnings("unchecked")
@Override//from w  ww . ja va 2  s . c  om
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public List<AttrClass> findByOwner(long ownerId) {
    Query query = entityManager
            .createQuery("from " + getEntityClass().getSimpleName() + " where owner_id = :ownerId");
    query.setParameter("ownerId", ownerId);
    return (List<AttrClass>) query.getResultList();
}

From source file:com.inkubator.hrm.service.impl.ProscessToApproveServiceImpl.java

@Override
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, propagation = Propagation.SUPPORTS, timeout = 30)
public ProscessToApprove getEntiyByPK(Long id) throws Exception {
    return this.proscessToApproveDao.getEntiyByPK(id);
}

From source file:de.crowdcode.bitemporal.example.PersonServiceImpl.java

@Override
@Transactional(propagation = Propagation.SUPPORTS)
public Person findPersonById(Long id) {
    Person person = personRepository.findById(id);
    return person;
}