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:cs544.wamp_blog_engine.dao.impl.CategoryDAOImpl.java

@Transactional(propagation = Propagation.SUPPORTS)
@Override//from  w  w w .  j ava  2s.  c  o  m
public Category getCategory(int categoryid) {
    Category category = (Category) sf.getCurrentSession().get(Category.class, categoryid);
    return category;
}

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

@Transactional(propagation = Propagation.SUPPORTS)
@Override/*from w  w w  .  j ava 2 s .c  om*/
public List<Product> getAllProducts() {

    Query query = sf.getCurrentSession().createQuery("from Product");
    List<Product> products = query.list();

    return products;
}

From source file:org.wallride.service.SystemService.java

@Async
@Transactional(propagation = Propagation.SUPPORTS)
public void reIndex() throws Exception {
    logger.info("Re-Index started");

    FullTextSession fullTextSession = Search.getFullTextSession((entityManager.unwrap(Session.class)));

    fullTextSession.setFlushMode(FlushMode.MANUAL);
    fullTextSession.setCacheMode(CacheMode.IGNORE);

    for (Class persistentClass : fullTextSession.getSearchFactory().getIndexedTypes()) {
        Transaction transaction = fullTextSession.beginTransaction();

        // Scrollable results will avoid loading too many objects in memory
        ScrollableResults results = fullTextSession.createCriteria(persistentClass).setFetchSize(BATCH_SIZE)
                .scroll(ScrollMode.FORWARD_ONLY);
        int index = 0;
        while (results.next()) {
            index++;//from   www .  j av a2s  . c  o m
            fullTextSession.index(results.get(0)); //index each element
            if (index % BATCH_SIZE == 0) {
                fullTextSession.flushToIndexes(); //apply changes to indexes
                fullTextSession.clear(); //free memory since the queue is processed
            }
        }
        transaction.commit();
    }
    logger.info("Re-Index finished");
}

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

@Transactional(propagation = Propagation.SUPPORTS)
@Override/*  w ww  . j  av  a  2s .  c o m*/
public List<Course> getCoursesWith(String words) {
    List<Course> courses;

    Query query = sf.getCurrentSession().createQuery("from Course c Where c.courseName like words");
    //query.setParameter("name",words);
    courses = query.list();

    return courses;
}

From source file:cs544.wamp_blog_engine.dao.impl.TagDAOImpl.java

@Transactional(propagation = Propagation.SUPPORTS)
@Override/*from  www  . j a  v a2s  .c o  m*/
public List<Tag> getAllTags() {

    Query query = sf.getCurrentSession().createQuery("from Tag");
    List<Tag> tags = query.list();
    return tags;
}

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

/**
 * /* w  w w .  j a  v  a 2 s. c  o  m*/
 * @returns only active faculties
 */
@Transactional(propagation = Propagation.SUPPORTS)
@Override
public List<Faculty> getAllActiveFaculties() {
    List<Faculty> faculties;
    Query query = sf.getCurrentSession().createQuery("from Faculty Where active=true");
    faculties = query.list();

    return faculties;
}

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

@Transactional(propagation = Propagation.SUPPORTS)
@Override/*from   w  w w  .  j  av  a2  s  . c om*/
public List<Credential> getAllCredentials() {
    Query query = sf.getCurrentSession().createQuery("from Credential");
    List<Credential> credentials = query.list();
    return credentials;
}

From source file:org.horizontaldb.example.model.dao.DepartmentDaoImpl.java

@Override
@SuppressWarnings("unchecked")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public Collection<Department> getAllDepartments() {
    Query query = getQueryBuilder().query("from Department").build();

    List<Department> retval = query.list();

    return retval;
}

From source file:cs544.wamp_blog_engine.dao.impl.BlogDAOImpl.java

@Transactional(propagation = Propagation.SUPPORTS)
@Override/* ww  w.  ja  v a2  s .co m*/
public List<Blog> getAllBlogs() {
    Query query = sf.getCurrentSession().createQuery("from Blog");
    List<Blog> blogs = query.list();
    return blogs;
}

From source file:cs544.wamp_blog_engine.dao.impl.RatingDAOImpl.java

@Transactional(propagation = Propagation.SUPPORTS)
@Override/*from  ww  w. j av a  2  s  .co  m*/
public List<Rating> getAllRatings() {
    Query query = sf.getCurrentSession().createQuery("from Rating");
    List<Rating> rating = query.list();
    return rating;
}