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

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

Introduction

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

Prototype

Propagation REQUIRED

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

Click Source Link

Document

Support a current transaction, create a new one if none exists.

Usage

From source file:com.teemo.service.UserService.java

@Transactional(propagation = Propagation.REQUIRED, rollbackFor = { RuntimeException.class })
public User register(User user) {
    String salt = randomSalt();//from w ww .  j av a 2  s . co m
    user.setSalt(salt);
    String password = encryptPassword(user.getUsername(), user.getPassword(), salt);
    user.setPassword(password);
    Long id = (Long) save(user);
    user.setId(id);
    return user;
}

From source file:dao.DAOComentario.java

/**
 * //from   ww w . j a va  2  s.c om
 * @param _comentario 
 */
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = exceptionsDAO.BorrarComentarioException.class)
public void borrarComentario(Comentario _comentario) {
    em.remove(em.merge(_comentario));
}

From source file:com.Services.Impl.Players.SoccerPlayer_CrudImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED)
public Soccer_player remove(Soccer_player entity) {
    return null;
}

From source file:cs544.wamp_blog_engine.service.impl.BlogService.java

@Transactional(propagation = Propagation.REQUIRED)
@Override
public void removeBlog(Blog blog) {
    blogDAO.removeBlog(blog);
}

From source file:uk.org.funcube.fcdw.server.extract.csv.HighResCsvExtractor.java

@Transactional(readOnly = true, propagation = Propagation.REQUIRED)
public void extract(long satelliteId) {

    Timestamp latestSatelliteTime = highResolutionDao.getLatestSatelliteTime(satelliteId);

    Timestamp since = new Timestamp(latestSatelliteTime.getTime() - (60 * 60 * 1000));

    List<HighResolutionEntity> highResOneHour = highResolutionDao.getSinceSatelliteTime(satelliteId, since);

    if (highResOneHour.size() == 0) {
        return;// w w w  .  jav a 2 s.c om
    }

    File fileLocation = new File(System.getProperty("csv.hires"));

    if (fileLocation.exists()) {
        fileLocation.delete();
    }

    try {
        // use FileWriter constructor that specifies open for appending
        CsvWriter csvOutput = new CsvWriter(new FileWriter(fileLocation, true), ',');

        // write out the headers
        csvOutput.write("Satellite Date/Time UTC");
        csvOutput.write("Sun Sensor +X log Lux");
        csvOutput.write("Sun Sensor +Y log Lux");
        csvOutput.write("Sun Sensor -Y log Lux");
        csvOutput.write("Sun Sensor +Z log Lux");
        csvOutput.write("Sun Sensor -Z log Lux");
        csvOutput.write("Tot. Photo Curr. mA");
        csvOutput.write("Battery mV");
        csvOutput.endRecord();

        long tsLong = 0;
        String c1 = "";
        String c2 = "";
        String c3 = "";
        String c4 = "";
        String c5 = "";
        String c6 = "";
        String c7 = "";

        for (HighResolutionEntity entity : highResOneHour) {

            Timestamp satelliteTime = entity.getSatelliteTime();

            if (tsLong == 0) {
                tsLong = satelliteTime.getTime();
                c1 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC1().intValue()]));
                c2 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC2().intValue()]));
                c3 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC3().intValue()]));
                c4 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC4().intValue()]));
                c5 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC5().intValue()]));
                c6 = String.format("%4.0f", new Double(entity.getC6() * 2.0));
                c7 = String.format("%3.0f", new Double(entity.getC7() * 2.0));

                writeRecord(csvOutput, satelliteTime, c1, c2, c3, c4, c5, c6, c7);
            } else {

                final long timeDiff = satelliteTime.getTime() - tsLong;
                if (timeDiff > 1000) {
                    // fill in the gaps
                    long gaps = (timeDiff / 1000);
                    for (long i = 1; i < gaps; i++) {
                        Timestamp intervalTime = new Timestamp(tsLong + (1000 * i));
                        writeRecord(csvOutput, intervalTime, c1, c2, c3, c4, c5, c6, c7);
                    }
                }

                c1 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC1().intValue()]));
                c2 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC2().intValue()]));
                c3 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC3().intValue()]));
                c4 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC4().intValue()]));
                c5 = String.format("%5.3f", new Double(SOL_ILLUMINATION[entity.getC5().intValue()]));
                c6 = String.format("%4.0f", new Double(entity.getC6() * 2.0));
                c7 = String.format("%3.0f", new Double(entity.getC7() * 2.0));

                writeRecord(csvOutput, satelliteTime, c1, c2, c3, c4, c5, c6, c7);

                tsLong = satelliteTime.getTime();
            }
        }

        csvOutput.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:com.webfileanalyzer.service.impl.FilesServiceImpl.java

@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
@Override
public void add(Files dbFile) {
    clearCache();
    filesDAO.add(dbFile);
}

From source file:com.Services.Impl.PlayerRecords.Bowler_CrudImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED)
public BowlerWickets remove(BowlerWickets entity) {
    return null;
}

From source file:com.webfileanalyzer.service.impl.FileStatisticServiceImpl.java

@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
@Override
public void add(FileStatistic dbFile) {
    clearCache();
    fileStatisticDAO.add(dbFile);
}

From source file:com.avaje.test.springsupport.UserServiceImpl.java

@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public void save(User user) {
    ebeanServer.save(user);
}

From source file:com.Services.Impl.SportRecords.RugbyRecords_CrudImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED)
public Rugby_Records remove(Rugby_Records entity) {
    return null;
}