Skip to content
Snippets Groups Projects
Commit 95023400 authored by 汤伟's avatar 汤伟 Committed by Wei
Browse files

minor modification to fit api

parent e0470ce9
No related branches found
No related tags found
No related merge requests found
Showing
with 90 additions and 53 deletions
...@@ -77,6 +77,12 @@ ...@@ -77,6 +77,12 @@
<version>1.18.24</version> <version>1.18.24</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId> <artifactId>junit-jupiter</artifactId>
...@@ -84,5 +90,5 @@ ...@@ -84,5 +90,5 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -31,7 +31,7 @@ public class Attribute { ...@@ -31,7 +31,7 @@ public class Attribute {
private Date gmtModified; private Date gmtModified;
protected Attribute(Long ID, Long entityID, Long viewID, String name, DataType dataType, protected Attribute(Long ID, Long entityID, Long viewID, String name, DataType dataType,
int isPrimary, LayoutInfo layoutInfo, Date gmtCreate, Date gmtModified) { int isPrimary, LayoutInfo layoutInfo, Double layoutX, Double layoutY, Date gmtCreate, Date gmtModified) {
this.ID = ID; this.ID = ID;
this.entityID = entityID; this.entityID = entityID;
this.viewID = viewID; this.viewID = viewID;
...@@ -49,7 +49,7 @@ public class Attribute { ...@@ -49,7 +49,7 @@ public class Attribute {
} }
} }
if (this.layoutInfo == null) { if (this.layoutInfo == null) {
this.layoutInfo = new LayoutInfo(0L, this.ID, RelatedObjType.ATTRIBUTE, 0.0, 0.0, 0.0, 0.0); this.layoutInfo = new LayoutInfo(0L, this.ID, RelatedObjType.ATTRIBUTE, layoutX, layoutY, 0.0, 0.0);
} }
} }
......
...@@ -9,13 +9,14 @@ import org.apache.ibatis.session.SqlSession; ...@@ -9,13 +9,14 @@ import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder; import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.log4j.BasicConfigurator; import org.apache.log4j.BasicConfigurator;
import org.apache.commons.io.IOUtils;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.charset.Charset; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.*; import java.util.*;
...@@ -29,7 +30,7 @@ public class ER { ...@@ -29,7 +30,7 @@ public class ER {
public static LayoutInfoMapper layoutInfoMapper; public static LayoutInfoMapper layoutInfoMapper;
private static Map<Long, View> allViewsMap = new HashMap<>(); private static Map<Long, View> allViewsMap = new HashMap<>();
public static void connectDB(boolean useDBLog) throws IOException { public static void connectDB(boolean useDBLog) throws SQLException, IOException {
InputStream is = Resources.getResourceAsStream("mybatis-config.xml"); InputStream is = Resources.getResourceAsStream("mybatis-config.xml");
SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder(); SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
SqlSessionFactory sqlSessionFactory = sqlSessionFactoryBuilder.build(is); SqlSessionFactory sqlSessionFactory = sqlSessionFactoryBuilder.build(is);
...@@ -42,14 +43,15 @@ public class ER { ...@@ -42,14 +43,15 @@ public class ER {
if (useDBLog) { if (useDBLog) {
BasicConfigurator.configure(); BasicConfigurator.configure();
} }
createTables();
useDB = true; useDB = true;
} }
public static void createTables() throws Exception { private static void createTables() throws SQLException, IOException {
Connection conn = sqlSession.getConnection(); Connection conn = sqlSession.getConnection();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
String content = Files.readString(Path.of("src/main/resources/sql/schema-v1.sql"), Charset.defaultCharset()); String sql = new String(Resources.getResourceAsStream("schema-v1.sql").readAllBytes(), StandardCharsets.UTF_8);
stmt.execute(content); stmt.execute(sql);
} }
public static View createView(String name, String creator) { public static View createView(String name, String creator) {
...@@ -72,6 +74,14 @@ public class ER { ...@@ -72,6 +74,14 @@ public class ER {
} }
} }
public static View queryViewByID(Long ID) {
if (ER.useDB) {
return View.queryByID(ID);
} else {
return allViewsMap.get(ID);
}
}
public static View loadFromJSON(String json) throws ERException { public static View loadFromJSON(String json) throws ERException {
try { try {
View view = new ObjectMapper().readValue(json, View.class); View view = new ObjectMapper().readValue(json, View.class);
......
...@@ -26,7 +26,7 @@ public class Entity { ...@@ -26,7 +26,7 @@ public class Entity {
@JsonIgnore @JsonIgnore
private Date gmtModified; private Date gmtModified;
protected Entity(Long ID, String name, Long viewID, List<Attribute> attributeList, LayoutInfo layoutInfo, Date gmtCreate, Date gmtModified) { protected Entity(Long ID, String name, Long viewID, List<Attribute> attributeList, LayoutInfo layoutInfo, Double layoutX, Double layoutY, Date gmtCreate, Date gmtModified) {
this.ID = ID; this.ID = ID;
this.name = name; this.name = name;
this.viewID = viewID; this.viewID = viewID;
...@@ -42,17 +42,20 @@ public class Entity { ...@@ -42,17 +42,20 @@ public class Entity {
} }
} }
if (this.layoutInfo == null) { if (this.layoutInfo == null) {
this.layoutInfo = new LayoutInfo(0L, this.ID, RelatedObjType.ENTITY, 0.0, 0.0, 0.0, 0.0); this.layoutInfo = new LayoutInfo(0L, this.ID, RelatedObjType.ENTITY, layoutX, layoutY, 0.0, 0.0);
} }
} }
public Attribute addAttribute(String attributeName, DataType dataType, int isPrimary) { public Attribute addAttribute(String attributeName, DataType dataType, int isPrimary) {
Attribute attribute = new Attribute(0L, this.ID, this.viewID, attributeName, dataType, isPrimary, null, new Date(), new Date()); Attribute attribute = new Attribute(0L, this.ID, this.viewID, attributeName, dataType, isPrimary, null, 0.0, 0.0, new Date(), new Date());
this.attributeList.add(attribute);
return attribute;
}
public Attribute addAttribute(String attributeName, DataType dataType, int isPrimary, Double layoutX, Double layoutY) {
Attribute attribute = new Attribute(0L, this.ID, this.viewID, attributeName, dataType, isPrimary, null, layoutX, layoutY, new Date(), new Date());
this.attributeList.add(attribute); this.attributeList.add(attribute);
if (ER.useDB) {
this.updateInfo(null);
}
return attribute; return attribute;
} }
...@@ -60,7 +63,6 @@ public class Entity { ...@@ -60,7 +63,6 @@ public class Entity {
this.attributeList.remove(attribute); this.attributeList.remove(attribute);
if (ER.useDB) { if (ER.useDB) {
attribute.deleteDB(); attribute.deleteDB();
this.updateInfo(null);
} }
return false; return false;
} }
...@@ -79,6 +81,9 @@ public class Entity { ...@@ -79,6 +81,9 @@ public class Entity {
} }
protected void deleteDB() { protected void deleteDB() {
for (Attribute attribute : attributeList) {
attribute.deleteDB();
}
ER.entityMapper.deleteByID(this.ID); ER.entityMapper.deleteByID(this.ID);
} }
......
...@@ -24,7 +24,7 @@ public class Trans { ...@@ -24,7 +24,7 @@ public class Trans {
LayoutInfo layoutInfo = LayoutInfo.queryByObjIDAndObjType(attributeDO.getID(), RelatedObjType.ATTRIBUTE); LayoutInfo layoutInfo = LayoutInfo.queryByObjIDAndObjType(attributeDO.getID(), RelatedObjType.ATTRIBUTE);
return new Attribute(attributeDO.getID(), attributeDO.getEntityID(), attributeDO.getViewID(), return new Attribute(attributeDO.getID(), attributeDO.getEntityID(), attributeDO.getViewID(),
attributeDO.getName(), attributeDO.getDataType(), attributeDO.getIsPrimary(), attributeDO.getName(), attributeDO.getDataType(), attributeDO.getIsPrimary(),
layoutInfo, attributeDO.getGmtCreate(), attributeDO.getGmtModified()); layoutInfo, 0.0, 0.0, attributeDO.getGmtCreate(), attributeDO.getGmtModified());
} }
protected static List<Attribute> TransAttributeListFromDB(List<AttributeDO> doList) { protected static List<Attribute> TransAttributeListFromDB(List<AttributeDO> doList) {
...@@ -38,7 +38,7 @@ public class Trans { ...@@ -38,7 +38,7 @@ public class Trans {
protected static Entity TransformFromDB(EntityDO entityDO) { protected static Entity TransformFromDB(EntityDO entityDO) {
List<Attribute> attributeList = Attribute.queryByAttribute(new AttributeDO(entityDO.getID(), entityDO.getViewID())); List<Attribute> attributeList = Attribute.queryByAttribute(new AttributeDO(entityDO.getID(), entityDO.getViewID()));
LayoutInfo layoutInfo = LayoutInfo.queryByObjIDAndObjType(entityDO.getID(), RelatedObjType.ENTITY); LayoutInfo layoutInfo = LayoutInfo.queryByObjIDAndObjType(entityDO.getID(), RelatedObjType.ENTITY);
return new Entity(entityDO.getID(), entityDO.getName(), entityDO.getViewID(), attributeList, layoutInfo, return new Entity(entityDO.getID(), entityDO.getName(), entityDO.getViewID(), attributeList, layoutInfo, null, null,
entityDO.getGmtCreate(), entityDO.getGmtModified()); entityDO.getGmtCreate(), entityDO.getGmtModified());
} }
......
...@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; ...@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.ic.er.Exception.ERException; import com.ic.er.Exception.ERException;
import com.ic.er.common.DataType;
import com.ic.er.common.ViewDeserializer; import com.ic.er.common.ViewDeserializer;
import com.ic.er.entity.ViewDO; import com.ic.er.entity.ViewDO;
import com.ic.er.common.Cardinality; import com.ic.er.common.Cardinality;
...@@ -49,11 +50,14 @@ public class View { ...@@ -49,11 +50,14 @@ public class View {
} }
public Entity addEntity(String entityName) { public Entity addEntity(String entityName) {
Entity entity = new Entity(0L, entityName, this.ID, new ArrayList<>(), null, new Date(), new Date()); Entity entity = new Entity(0L, entityName, this.ID, new ArrayList<>(), null, 0.0, 0.0, new Date(), new Date());
this.entityList.add(entity);
return entity;
}
public Entity addEntity(String entityName, Double layoutX, Double layoutY) {
Entity entity = new Entity(0L, entityName, this.ID, new ArrayList<>(), null, layoutX, layoutY, new Date(), new Date());
this.entityList.add(entity); this.entityList.add(entity);
if (ER.useDB) {
this.updateInfo(null);
}
return entity; return entity;
} }
...@@ -61,7 +65,6 @@ public class View { ...@@ -61,7 +65,6 @@ public class View {
this.entityList.remove(entity); this.entityList.remove(entity);
if (ER.useDB) { if (ER.useDB) {
entity.deleteDB(); entity.deleteDB();
this.updateInfo(null);
} }
return false; return false;
} }
...@@ -70,18 +73,14 @@ public class View { ...@@ -70,18 +73,14 @@ public class View {
Cardinality firstCardinality, Cardinality secondCardinality) { Cardinality firstCardinality, Cardinality secondCardinality) {
Relationship relationship = new Relationship(0L, relationshipName, this.ID, Relationship relationship = new Relationship(0L, relationshipName, this.ID,
firstEntity, secondEntity, firstCardinality, secondCardinality, null, new Date(), new Date()); firstEntity, secondEntity, firstCardinality, secondCardinality, null, new Date(), new Date());
this.getRelationshipList().add(relationship); this.relationshipList.add(relationship);
if (ER.useDB) {
this.updateInfo(null);
}
return relationship; return relationship;
} }
public boolean deleteRelationship(Relationship relationship) { public boolean deleteRelationship(Relationship relationship) {
this.getRelationshipList().remove(relationship); this.relationshipList.remove(relationship);
if (ER.useDB) { if (ER.useDB) {
relationship.deleteDB(); relationship.deleteDB();
this.updateInfo(null);
} }
return false; return false;
} }
...@@ -99,10 +98,6 @@ public class View { ...@@ -99,10 +98,6 @@ public class View {
} }
} }
public static List<View> queryAll() {
return Trans.TransViewListFromDB(ER.viewMapper.selectAll());
}
public String ToJSON() { public String ToJSON() {
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter(); ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json; String json;
...@@ -114,6 +109,10 @@ public class View { ...@@ -114,6 +109,10 @@ public class View {
return json; return json;
} }
public static List<View> queryAll() {
return Trans.TransViewListFromDB(ER.viewMapper.selectAll());
}
public static List<View> queryByView(ViewDO ViewDO) { public static List<View> queryByView(ViewDO ViewDO) {
List<ViewDO> viewDOList = ER.viewMapper.selectByView(ViewDO); List<ViewDO> viewDOList = ER.viewMapper.selectByView(ViewDO);
return Trans.TransViewListFromDB(viewDOList); return Trans.TransViewListFromDB(viewDOList);
...@@ -129,6 +128,13 @@ public class View { ...@@ -129,6 +128,13 @@ public class View {
} }
protected void deleteDB() { protected void deleteDB() {
// cascade delete the entities and relationships in this view
for (Entity entity : entityList) {
entity.deleteDB();
}
for (Relationship relationship : relationshipList) {
relationship.deleteDB();
}
ER.viewMapper.deleteByID(this.ID); ER.viewMapper.deleteByID(this.ID);
} }
......
package com.ic.er.common;
public enum DataType {
UNKNOWN,
CHAR,
VARCHAR,
TEXT,
TINYINT,
SMALLINT,
INT,
BIGINT,
FLOAT,
DOUBLE,
DATETIME,
}
...@@ -17,7 +17,6 @@ public class TestAttribute { ...@@ -17,7 +17,6 @@ public class TestAttribute {
@Before @Before
public void init() throws Exception { public void init() throws Exception {
ER.connectDB(true); ER.connectDB(true);
ER.createTables();
testView = ER.createView("testView", "wt22"); testView = ER.createView("testView", "wt22");
testEntity = testView.addEntity("teacher"); testEntity = testView.addEntity("teacher");
} }
...@@ -26,7 +25,7 @@ public class TestAttribute { ...@@ -26,7 +25,7 @@ public class TestAttribute {
public void addAttributeTest() { public void addAttributeTest() {
Attribute a1 = testEntity.addAttribute("teacher_id", DataType.VARCHAR, 1); Attribute a1 = testEntity.addAttribute("teacher_id", DataType.VARCHAR, 1);
Attribute a2 = testEntity.addAttribute("name", DataType.VARCHAR, 0); Attribute a2 = testEntity.addAttribute("name", DataType.VARCHAR, 0);
Attribute a3 = testEntity.addAttribute("age", DataType.INTEGER, 0); Attribute a3 = testEntity.addAttribute("age", DataType.INT, 0);
System.out.printf("a1 ID: %d\n", a1.getID()); System.out.printf("a1 ID: %d\n", a1.getID());
System.out.printf("a2 ID: %d\n", a2.getID()); System.out.printf("a2 ID: %d\n", a2.getID());
System.out.printf("a3 ID: %d\n", a3.getID()); System.out.printf("a3 ID: %d\n", a3.getID());
......
...@@ -11,7 +11,6 @@ public class TestER { ...@@ -11,7 +11,6 @@ public class TestER {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
ER.connectDB(true); ER.connectDB(true);
ER.createTables();
} }
@Test @Test
...@@ -35,12 +34,12 @@ public class TestER { ...@@ -35,12 +34,12 @@ public class TestER {
Entity teacher = firstView.addEntity("teacher"); Entity teacher = firstView.addEntity("teacher");
teacher.addAttribute("teacher_id", DataType.VARCHAR, 1); teacher.addAttribute("teacher_id", DataType.VARCHAR, 1);
teacher.addAttribute("name", DataType.VARCHAR, 0); teacher.addAttribute("name", DataType.VARCHAR, 0);
teacher.addAttribute("age", DataType.INTEGER, 0); teacher.addAttribute("age", DataType.INT, 0);
Entity student = firstView.addEntity("student"); Entity student = firstView.addEntity("student");
student.addAttribute("student_id", DataType.VARCHAR, 1); student.addAttribute("student_id", DataType.VARCHAR, 1);
student.addAttribute("name", DataType.VARCHAR, 0); student.addAttribute("name", DataType.VARCHAR, 0);
student.addAttribute("grade", DataType.INTEGER, 0); student.addAttribute("grade", DataType.INT, 0);
Relationship ts = firstView.createRelationship("teaches", teacher, student, Cardinality.OneToMany, Cardinality.OneToMany); Relationship ts = firstView.createRelationship("teaches", teacher, student, Cardinality.OneToMany, Cardinality.OneToMany);
...@@ -49,7 +48,7 @@ public class TestER { ...@@ -49,7 +48,7 @@ public class TestER {
View view = ER.loadFromJSON(jsonString); View view = ER.loadFromJSON(jsonString);
Assert.assertNotNull(view); Assert.assertNotNull(view);
} }
@Test @Test
public void getCardi() { public void getCardi() {
System.out.println(Cardinality.getFromValue("1:N")); System.out.println(Cardinality.getFromValue("1:N"));
......
...@@ -14,7 +14,6 @@ public class TestEntity { ...@@ -14,7 +14,6 @@ public class TestEntity {
@Before @Before
public void init() throws Exception { public void init() throws Exception {
ER.connectDB(true); ER.connectDB(true);
ER.createTables();
testView = ER.createView("testView", "wt22"); testView = ER.createView("testView", "wt22");
} }
...@@ -57,7 +56,7 @@ public class TestEntity { ...@@ -57,7 +56,7 @@ public class TestEntity {
@Test(expected = ERException.class) @Test(expected = ERException.class)
public void attributeTest() { public void attributeTest() {
Entity teacher = testView.addEntity("teacher"); Entity teacher = testView.addEntity("teacher");
Attribute teacherID = teacher.addAttribute("teacher_id", DataType.INTEGER, 1); Attribute teacherID = teacher.addAttribute("teacher_id", DataType.INT, 1);
Assert.assertNotEquals(teacher.getID(), Long.valueOf(0)); Assert.assertNotEquals(teacher.getID(), Long.valueOf(0));
teacher.updateInfo("new teacher name"); teacher.updateInfo("new teacher name");
......
...@@ -18,7 +18,6 @@ public class TestRelationship { ...@@ -18,7 +18,6 @@ public class TestRelationship {
@Before @Before
public void init() throws Exception { public void init() throws Exception {
ER.connectDB(true); ER.connectDB(true);
ER.createTables();
testView = ER.createView("testView", "wt22"); testView = ER.createView("testView", "wt22");
teacher = testView.addEntity("teacher"); teacher = testView.addEntity("teacher");
student = testView.addEntity("student"); student = testView.addEntity("student");
......
...@@ -18,7 +18,6 @@ public class TestView { ...@@ -18,7 +18,6 @@ public class TestView {
@Before @Before
public void init() throws Exception { public void init() throws Exception {
ER.connectDB(true); ER.connectDB(true);
ER.createTables();
} }
@Test @Test
...@@ -28,12 +27,12 @@ public class TestView { ...@@ -28,12 +27,12 @@ public class TestView {
Entity teacher = testView.addEntity("teacher"); Entity teacher = testView.addEntity("teacher");
teacher.addAttribute("teacher_id", DataType.VARCHAR, 1); teacher.addAttribute("teacher_id", DataType.VARCHAR, 1);
teacher.addAttribute("name", DataType.VARCHAR, 0); teacher.addAttribute("name", DataType.VARCHAR, 0);
teacher.addAttribute("age", DataType.INTEGER, 0); teacher.addAttribute("age", DataType.INT, 0);
Entity student = testView.addEntity("student"); Entity student = testView.addEntity("student");
student.addAttribute("student_id", DataType.VARCHAR, 1); student.addAttribute("student_id", DataType.VARCHAR, 1);
student.addAttribute("name", DataType.VARCHAR, 0); student.addAttribute("name", DataType.VARCHAR, 0);
student.addAttribute("grade", DataType.INTEGER, 0); student.addAttribute("grade", DataType.INT, 0);
Relationship ts = testView.createRelationship("teaches", teacher, student, Cardinality.ZeroToMany, Cardinality.ZeroToMany); Relationship ts = testView.createRelationship("teaches", teacher, student, Cardinality.ZeroToMany, Cardinality.ZeroToMany);
...@@ -98,12 +97,12 @@ public class TestView { ...@@ -98,12 +97,12 @@ public class TestView {
Entity teacher = firstView.addEntity("teacher"); Entity teacher = firstView.addEntity("teacher");
teacher.addAttribute("teacher_id", DataType.VARCHAR, 1); teacher.addAttribute("teacher_id", DataType.VARCHAR, 1);
teacher.addAttribute("name", DataType.VARCHAR, 0); teacher.addAttribute("name", DataType.VARCHAR, 0);
teacher.addAttribute("age", DataType.INTEGER, 0); teacher.addAttribute("age", DataType.INT, 0);
Entity student = firstView.addEntity("student"); Entity student = firstView.addEntity("student");
student.addAttribute("student_id", DataType.VARCHAR, 1); student.addAttribute("student_id", DataType.VARCHAR, 1);
student.addAttribute("name", DataType.VARCHAR, 0); student.addAttribute("name", DataType.VARCHAR, 0);
student.addAttribute("grade", DataType.INTEGER, 0); student.addAttribute("grade", DataType.INT, 0);
Relationship ts = firstView.createRelationship("teaches", teacher, student, Cardinality.ZeroToMany, Cardinality.ZeroToMany); Relationship ts = firstView.createRelationship("teaches", teacher, student, Cardinality.ZeroToMany, Cardinality.ZeroToMany);
Assert.assertNotNull(ts); Assert.assertNotNull(ts);
......
...@@ -20,7 +20,6 @@ public class attributeMapperTest { ...@@ -20,7 +20,6 @@ public class attributeMapperTest {
@Before @Before
public void init() throws Exception { public void init() throws Exception {
ER.connectDB(true); ER.connectDB(true);
ER.createTables();
} }
@Test @Test
...@@ -43,9 +42,9 @@ public class attributeMapperTest { ...@@ -43,9 +42,9 @@ public class attributeMapperTest {
Date gmtModified = new Date(); Date gmtModified = new Date();
AttributeDO attributeDO = new AttributeDO(0L, entityID, viewID, name, DataType.INTEGER, isPrimary, isDelete, gmtCreate, gmtModified); AttributeDO attributeDO = new AttributeDO(0L, entityID, viewID, name, DataType.INT, isPrimary, isDelete, gmtCreate, gmtModified);
AttributeDO attributeDO2 = new AttributeDO(0L, entityID, viewID, name, DataType.INTEGER, isPrimary, isDelete, gmtCreate, gmtModified); AttributeDO attributeDO2 = new AttributeDO(0L, entityID, viewID, name, DataType.INT, isPrimary, isDelete, gmtCreate, gmtModified);
AttributeDO attributeDO3 = new AttributeDO(0L, entityID, viewID, name, DataType.INTEGER, isPrimary, isDelete, gmtCreate, gmtModified); AttributeDO attributeDO3 = new AttributeDO(0L, entityID, viewID, name, DataType.INT, isPrimary, isDelete, gmtCreate, gmtModified);
int ret = ER.attributeMapper.insert(attributeDO); int ret = ER.attributeMapper.insert(attributeDO);
int ret2 = ER.attributeMapper.insert(attributeDO2); int ret2 = ER.attributeMapper.insert(attributeDO2);
......
...@@ -10,6 +10,7 @@ import org.junit.Test; ...@@ -10,6 +10,7 @@ import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException;
public class testMybatis { public class testMybatis {
...@@ -28,7 +29,7 @@ public class testMybatis { ...@@ -28,7 +29,7 @@ public class testMybatis {
} }
@Test @Test
public void testDBConnection() throws IOException { public void testDBConnection() throws IOException, SQLException {
ER.connectDB(true); ER.connectDB(true);
Assert.assertNotNull(ER.sqlSession); Assert.assertNotNull(ER.sqlSession);
System.out.println(ER.sqlSession.getConnection()); System.out.println(ER.sqlSession.getConnection());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment