com.javaoffers.base.modelhelper.sample.HelpSample Maven / Gradle / Ivy
The newest version!
package com.javaoffers.base.modelhelper.sample;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.javaoffers.base.modelhelper.sample.utils.LOGUtils;
import com.javaoffers.brief.modelhelper.aggent.InstallModelHelper;
import com.javaoffers.brief.modelhelper.anno.derive.flag.Version;
import com.javaoffers.brief.modelhelper.core.ConvertRegisterSelectorDelegate;
import com.javaoffers.brief.modelhelper.core.Id;
import org.apache.ibatis.builder.xml.XMLConfigBuilder;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.Test;
import java.io.InputStream;
import java.math.BigDecimal;
import java.sql.Time;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.util.Date;
import java.util.List;
public class HelpSample {
ObjectMapper objectMapper = new ObjectMapper();
@Before
public void before(){
InstallModelHelper.install();
}
@Test
public void test1() throws JsonProcessingException {
InputStream is = HelpSample.class.getResourceAsStream("/sqlMapConfig.xml");
Configuration configuration = new XMLConfigBuilder(is, null, null).parse();
//以下的这种办法不行,因为在 上面的parse()方法执行过程中就已经触发resultType=model类型未找到,因此需要在配置文件中指定。
// 本人没有指定。利用byteBuddy进行修改字节操作,如下案例
// TypeAliasRegistry typeAliasRegistry = configuration.getTypeAliasRegistry();
// typeAliasRegistry .registerAlias("model", HashMap.class);
SqlSessionFactory sf = new SqlSessionFactoryBuilder().build(configuration);
SqlSession sqlSession = sf.openSession();
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy