Skip to content
Snippets Groups Projects
Commit a68af167 authored by Wendi HAN's avatar Wendi HAN Committed by Wei
Browse files

example test

parent 6c2672c4
No related branches found
No related tags found
No related merge requests found
......@@ -21,14 +21,14 @@
id, entity_id, view_id, name, data_type, is_primary, is_foreign
</sql>
<select id="selectById" parameterType="java.lang.Long">
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
id,entity_id,view_id,name,data_type,is_primary,is_foreign,is_delete,gmt_create,gmt_modified
from attribute
where id = #{id,jdbcType=BIGINT} and is_delete = 0
</select>
<select id="selectByAttribute" parameterType="com.ic.er.bean.entity.AttributeDO">
<select id="selectByAttribute" parameterType="com.ic.er.bean.entity.AttributeDO" resultMap="BaseResultMap">
select
id,entity_id,view_id,name,data_type,is_primary,is_foreign,is_delete,gmt_create,gmt_modified
from attribute
......
......@@ -17,14 +17,14 @@
id, name, view_id
</sql>
<select id="selectById" parameterType="java.lang.Long">
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
id,name,view_id,is_delete,gmt_create,gmt_modified
from entity
where id = #{id,jdbcType=BIGINT} and is_delete = 0
</select>
<select id="selectByEntity" parameterType="com.ic.er.bean.entity.EntityDO">
<select id="selectByEntity" parameterType="com.ic.er.bean.entity.EntityDO" resultMap="BaseResultMap">
select
id,name,view_id,is_delete,gmt_create,gmt_modified
from entity
......
......@@ -22,14 +22,14 @@
id, name, view_id, first_entity_id, second_entity_id, first_attribute_id, second_attribute_id, cardinality
</sql>
<select id="selectById" parameterType="java.lang.Long">
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
id,name,view_id,first_entity_id,second_entity_id,first_attribute_id,second_attribute_id,cardinality,is_delete,gmt_create,gmt_modified
from relationship
where id = #{id,jdbcType=BIGINT} and is_delete = 0
</select>
<select id="selectByRelationship" parameterType="com.ic.er.bean.entity.RelationshipDO">
<select id="selectByRelationship" parameterType="com.ic.er.bean.entity.RelationshipDO" resultMap="BaseResultMap">
select
id,name,view_id,first_entity_id,second_entity_id,first_attribute_id,second_attribute_id,cardinality,is_delete,gmt_create,gmt_modified
from relationship
......
......@@ -18,13 +18,13 @@
id, name, creator, parent_id
</sql>
<select id="selectAll">
<select id="selectAll" resultMap="BaseResultMap">
select
id,name,creator,parent_id,is_delete,gmt_create,gmt_modified
from view where is_delete = 0
</select>
<select id="selectByView" parameterType="com.ic.er.bean.entity.ViewDO">
<select id="selectByView" parameterType="com.ic.er.bean.entity.ViewDO" resultMap="BaseResultMap">
select
id,name,creator,parent_id,is_delete,gmt_create,gmt_modified
from view
......@@ -54,7 +54,7 @@
</trim>
</select>
<select id="selectById" parameterType="java.lang.Long">
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
id,name,creator,parent_id,is_delete,gmt_create,gmt_modified
from view
......
......@@ -13,18 +13,11 @@ import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.ResultSet;
/**
*
* @author wendi
* @data 15/10/2022
*
*/
public class testMybatis {
@Test
public void testMybatisConnect() throws IOException {
public void testMybatisConnect() {
try {
InputStream is = Resources.getResourceAsStream("mybatis-config.xml");
SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
......
package com.ic.er;
import com.ic.er.bean.entity.ViewDO;
import com.ic.er.dao.ViewMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.util.List;
public class testViewMapper {
public static SqlSession sqlSession;
public static Connection connection;
public static ViewMapper viewMapper;
@BeforeAll
public void beforeAllTests() {
@Before
public void init() throws IOException {
InputStream is = Resources.getResourceAsStream("mybatis-config.xml");
SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
SqlSessionFactory sqlSessionFactory = sqlSessionFactoryBuilder.build(is);
sqlSession = sqlSessionFactory.openSession(true);
connection = sqlSession.getConnection();
System.out.println(connection);
viewMapper = sqlSession.getMapper(ViewMapper.class);
}
@Test
public void testQueryAllViews() {
Assert.assertNotNull(sqlSession);
List<ViewDO> viewDOList = viewMapper.selectAll();
Assert.assertEquals(viewDOList.size(), 0);
}
}
......@@ -21,14 +21,14 @@
id, entity_id, view_id, name, data_type, is_primary, is_foreign
</sql>
<select id="selectById" parameterType="java.lang.Long">
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
id,entity_id,view_id,name,data_type,is_primary,is_foreign,is_delete,gmt_create,gmt_modified
from attribute
where id = #{id,jdbcType=BIGINT} and is_delete = 0
</select>
<select id="selectByAttribute" parameterType="com.ic.er.bean.entity.AttributeDO">
<select id="selectByAttribute" parameterType="com.ic.er.bean.entity.AttributeDO" resultMap="BaseResultMap">
select
id,entity_id,view_id,name,data_type,is_primary,is_foreign,is_delete,gmt_create,gmt_modified
from attribute
......
......@@ -17,14 +17,14 @@
id, name, view_id
</sql>
<select id="selectById" parameterType="java.lang.Long">
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
id,name,view_id,is_delete,gmt_create,gmt_modified
from entity
where id = #{id,jdbcType=BIGINT} and is_delete = 0
</select>
<select id="selectByEntity" parameterType="com.ic.er.bean.entity.EntityDO">
<select id="selectByEntity" parameterType="com.ic.er.bean.entity.EntityDO" resultMap="BaseResultMap">
select
id,name,view_id,is_delete,gmt_create,gmt_modified
from entity
......
......@@ -22,14 +22,14 @@
id, name, view_id, first_entity_id, second_entity_id, first_attribute_id, second_attribute_id, cardinality
</sql>
<select id="selectById" parameterType="java.lang.Long">
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
id,name,view_id,first_entity_id,second_entity_id,first_attribute_id,second_attribute_id,cardinality,is_delete,gmt_create,gmt_modified
from relationship
where id = #{id,jdbcType=BIGINT} and is_delete = 0
</select>
<select id="selectByRelationship" parameterType="com.ic.er.bean.entity.RelationshipDO">
<select id="selectByRelationship" parameterType="com.ic.er.bean.entity.RelationshipDO" resultMap="BaseResultMap">
select
id,name,view_id,first_entity_id,second_entity_id,first_attribute_id,second_attribute_id,cardinality,is_delete,gmt_create,gmt_modified
from relationship
......
......@@ -18,13 +18,13 @@
id, name, creator, parent_id
</sql>
<select id="selectAll">
<select id="selectAll" resultMap="BaseResultMap">
select
id,name,creator,parent_id,is_delete,gmt_create,gmt_modified
from view where is_delete = 0
</select>
<select id="selectByView" parameterType="com.ic.er.bean.entity.ViewDO">
<select id="selectByView" parameterType="com.ic.er.bean.entity.ViewDO" resultMap="BaseResultMap">
select
id,name,creator,parent_id,is_delete,gmt_create,gmt_modified
from view
......@@ -54,7 +54,7 @@
</trim>
</select>
<select id="selectById" parameterType="java.lang.Long">
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
id,name,creator,parent_id,is_delete,gmt_create,gmt_modified
from view
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment