All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jpattern.orm.jdbctemplate.JdbcTemplateSessionProvider Maven / Gradle / Ivy

There is a newer version: 5.3.0
Show newest version
package com.jpattern.orm.jdbctemplate;

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.PlatformTransactionManager;

import com.jpattern.orm.session.ISessionProvider;
import com.jpattern.orm.session.ISessionStrategy;

/**
 * 
 * @author Francesco Cina
 *
 * 15/giu/2011
 */
public class JdbcTemplateSessionProvider implements ISessionProvider {

	private final JdbcTemplate jdbcTemplate;
	private final PlatformTransactionManager platformTransactionManager;

	/**
	 * If the jporm instance has been created with this constructor the programmatic transaction management
	 * system will be disabled and the only way to manage transaction will be through the standard Spring
	 * TRANSACTIONAL annotation
	 * @param dataSource
	 */
	public JdbcTemplateSessionProvider(DataSource dataSource) {
		this( new JdbcTemplate(dataSource), new NullPlatformTransactionManager() );
	}

	/**
	 * If the jporm instance has been created with this constructor the programmatic transaction management
	 * system will be disabled and the only way to manage transaction will be through the standard Spring
	 * TRANSACTIONAL annotation
	 * @param dataSource
	 */
	public JdbcTemplateSessionProvider(JdbcTemplate jdbcTemplate) {
		this( jdbcTemplate, new NullPlatformTransactionManager() );
	}

	public JdbcTemplateSessionProvider(DataSource dataSource, PlatformTransactionManager platformTransactionManager) {
		this( new JdbcTemplate(dataSource), platformTransactionManager );
	}

	public JdbcTemplateSessionProvider(JdbcTemplate jdbcTemplate, PlatformTransactionManager platformTransactionManager) {
		this.jdbcTemplate = jdbcTemplate;
		this.platformTransactionManager = platformTransactionManager;
	}

	@Override
	public ISessionStrategy getSessionStrategy() {
		return new JdbcTemplateSessionStrategy(this.jdbcTemplate, this.platformTransactionManager);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy