com.sonsure.dumper.springjdbc.persist.SpringJdbcDaoTemplateImpl Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2020. www.sonsure.com Inc. All rights reserved.
* You may obtain more information at
*
* http://www.sonsure.com
*
* Designed By Selfly Lee ([email protected])
*/
package com.sonsure.dumper.springjdbc.persist;
import com.sonsure.dumper.core.config.JdbcEngineImpl;
import com.sonsure.dumper.core.convert.JdbcTypeConverter;
import com.sonsure.dumper.core.convert.SqliteCompatibleLocalDateTimeConverter;
import com.sonsure.dumper.core.exception.SonsureJdbcException;
import com.sonsure.dumper.core.persist.AbstractDaoTemplateImpl;
import com.sonsure.dumper.springjdbc.config.JdbcTemplateEngineConfigImpl;
import org.springframework.beans.factory.InitializingBean;
import java.util.Collections;
import java.util.List;
/**
* @author liyd
* @date 17/4/12
*/
public class SpringJdbcDaoTemplateImpl extends AbstractDaoTemplateImpl implements InitializingBean {
@Override
public void afterPropertiesSet() throws Exception {
if (defaultJdbcEngine == null) {
if (dataSource == null) {
throw new SonsureJdbcException("defaultJdbcEngine和dataSource不能同时为空");
}
JdbcTemplateEngineConfigImpl jdbcTemplateEngineConfig = new JdbcTemplateEngineConfigImpl();
jdbcTemplateEngineConfig.setDataSource(getDataSource());
final List jdbcTypeConverters = Collections.singletonList(new SqliteCompatibleLocalDateTimeConverter());
jdbcTemplateEngineConfig.setJdbcTypeConverters(jdbcTypeConverters);
defaultJdbcEngine = new JdbcEngineImpl(jdbcTemplateEngineConfig);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy