com.jpattern.orm.jdbctemplate.JdbcTemplateSessionStrategy Maven / Gradle / Ivy
The newest version!
package com.jpattern.orm.jdbctemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.PlatformTransactionManager;
import com.jpattern.orm.exception.OrmException;
import com.jpattern.orm.session.SessionStrategy;
import com.jpattern.orm.session.SqlPerformerStrategy;
import com.jpattern.orm.transaction.Transaction;
import com.jpattern.orm.transaction.TransactionDefinition;
/**
*
* @author Francesco Cina
*
* 15/giu/2011
*/
public class JdbcTemplateSessionStrategy implements SessionStrategy {
private final JdbcTemplate jdbcTemplate;
private final PlatformTransactionManager platformTransactionManager;
public JdbcTemplateSessionStrategy(JdbcTemplate jdbcTemplate, PlatformTransactionManager platformTransactionManager) {
this.jdbcTemplate = jdbcTemplate;
this.platformTransactionManager = platformTransactionManager;
}
@Override
public Transaction getTransaction(TransactionDefinition transactionDefinition) throws OrmException {
try {
return new JdbcTemplateTransaction(this.platformTransactionManager, transactionDefinition);
} catch (Exception e) {
throw new OrmException(e);
}
}
@Override
public SqlPerformerStrategy sqlPerformerStrategy() throws OrmException {
return new JdbcTemplateSqlPerformerStrategy( this.jdbcTemplate );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy