Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
BREWTAN committed Apr 10, 2016
1 parent 9a339c1 commit 7dc0a71
Show file tree
Hide file tree
Showing 982 changed files with 18,425 additions and 14,532 deletions.
1 change: 1 addition & 0 deletions RGenerator/src/main/java/Mybatis3StaticTableDao.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public class ${domainClazz}Dao extends ExtendDaoSupper<${domainClazz}, ${domainC
@Override
//@Transactional
public int batchInsert(List<${domainClazz}> records) throws Exception {
if(records.size()<=0)return 0;
SqlSession session=sqlSessionFactory.openSession();
Connection conn = session.getConnection();
Statement st = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ public static void main(String[] args) throws Exception {


}

for (String name : new String[] { "tfg" }) {
packShortName = name;

String xmlName = "generator-" + name + "-config-osgi.xml";
// String xmlName = "generator-" + name + "-config.xml";

Def.GEN_CTRL = xmlName.endsWith("config.xml");
testGenerateMyBatis(xmlName, tmpSource);


}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.mybatis.generator.api.dom.java.Field;
import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
import org.mybatis.generator.api.dom.java.InnerClass;
import org.mybatis.generator.api.dom.java.Interface;
import org.mybatis.generator.api.dom.java.JavaVisibility;
import org.mybatis.generator.api.dom.java.Method;
import org.mybatis.generator.api.dom.java.Parameter;
Expand Down Expand Up @@ -167,6 +168,8 @@ public boolean modelExampleClassGenerated(TopLevelClass topLevelClass,
field.setVisibility(JavaVisibility.PROTECTED);
topLevelClass.addField(field);



method = new Method();
method.setName("setGroupSelClause");
method.setVisibility(JavaVisibility.PUBLIC);
Expand All @@ -183,6 +186,32 @@ public boolean modelExampleClassGenerated(TopLevelClass topLevelClass,
method.setReturnType(FullyQualifiedJavaType.getStringInstance());
method.addBodyLine(" return groupSelClause;");
topLevelClass.addMethod(method);


//--add for update
field = new Field();
field.setName("forUpdate");
field.setType(FullyQualifiedJavaType.getBooleanPrimitiveInstance());
field.setVisibility(JavaVisibility.PROTECTED);
topLevelClass.addField(field);

method = new Method();
method.setName("setForUpdate");
method.setVisibility(JavaVisibility.PUBLIC);
method.addParameter(new Parameter(FullyQualifiedJavaType
.getBooleanPrimitiveInstance(), "forUpdate"));
method.setReturnType(null);
method.addBodyLine(" this.forUpdate = forUpdate;");

topLevelClass.addMethod(method);

method = new Method();
method.setName("isForUpdate");
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getBooleanPrimitiveInstance());
method.addBodyLine(" return forUpdate;");
topLevelClass.addMethod(method);
//=----

field = new Field();
field.setName("groupByClause");
Expand Down Expand Up @@ -214,6 +243,8 @@ public boolean modelExampleClassGenerated(TopLevelClass topLevelClass,
mod.addBodyLine("this.sumCol=null;");
mod.addBodyLine("this.groupSelClause=null;");
mod.addBodyLine("this.groupByClause=null;");
mod.addBodyLine("this.forUpdate=false;");

}
String examplename = introspectedTable.getExampleType().substring(
introspectedTable.getExampleType().lastIndexOf(".") + 1);
Expand All @@ -225,12 +256,14 @@ public boolean modelExampleClassGenerated(TopLevelClass topLevelClass,
return true;
}


@Override
public boolean providerGenerated(TopLevelClass topLevelClass,
IntrospectedTable introspectedTable) {
// TODO providerGenerated
String tableName = introspectedTable.getTableConfiguration()
.getTableName();

// ----------------truncate provider---------------
// Method method = new Method();
// method.setName("truncate");
Expand All @@ -242,6 +275,25 @@ public boolean providerGenerated(TopLevelClass topLevelClass,
return true;
}


@Override
public boolean clientSelectByPrimaryKeyMethodGenerated(Method method,
Interface interfaze, IntrospectedTable introspectedTable) {
// TODO Auto-generated method stub
return super.clientSelectByPrimaryKeyMethodGenerated(method, interfaze,
introspectedTable);
}


@Override
public boolean clientSelectByPrimaryKeyMethodGenerated(Method method,
TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
// TODO Auto-generated method stub
return super.clientSelectByPrimaryKeyMethodGenerated(method, topLevelClass,
introspectedTable);
}


@Override
public boolean providerSelectByExampleWithBLOBsMethodGenerated(
Method method, TopLevelClass topLevelClass,
Expand Down Expand Up @@ -286,12 +338,15 @@ public boolean providerSelectByExampleWithoutBLOBsMethodGenerated(
"\t\t}");

line.add("if(example != null){");
line.add("return SQL().concat(\" limit \"+example.getOffset()+\",\"+example.getLimit());");

line.add("String retstr= SQL().concat(\" limit \"+example.getOffset()+\",\"+example.getLimit());");

// line.add("return \"SELECT * FROM (SELECT A.*, ROWNUM RN FROM (\"+SQL()+\") A WHERE ROWNUM < \"+(example.getLimit()+example.getOffset())+\") WHERE RN >= \"+(example.getOffset()) ;");

// line.add("return \"SELECT * FROM (SELECT A.*, rownumber() over() as RN FROM (\"+SQL()+\") A ) WHERE RN < \"+(example.getLimit()+example.getOffset())+\" AND RN >= \"+(example.getOffset()) ;");

line.add("if(example.isForUpdate()) { return retstr+\" FOR UPDATE \" ;} else { return retstr;}");

line.add("}");
int linesNumber = method.getBodyLines().size();
method.addBodyLines(linesNumber - 1, line);
Expand Down
1 change: 1 addition & 0 deletions RGenerator/target/classes/Mybatis3StaticTableDao.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public class ${domainClazz}Dao extends ExtendDaoSupper<${domainClazz}, ${domainC
@Override
//@Transactional
public int batchInsert(List<${domainClazz}> records) throws Exception {
if(records.size()<=0)return 0;
SqlSession session=sqlSessionFactory.openSession();
Connection conn = session.getConnection();
Statement st = null;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ public static void main(String[] args) throws Exception {


}

for (String name : new String[] { "tfg" }) {
packShortName = name;

String xmlName = "generator-" + name + "-config-osgi.xml";
// String xmlName = "generator-" + name + "-config.xml";

Def.GEN_CTRL = xmlName.endsWith("config.xml");
testGenerateMyBatis(xmlName, tmpSource);


}

}

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.mybatis.generator.api.dom.java.Field;
import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
import org.mybatis.generator.api.dom.java.InnerClass;
import org.mybatis.generator.api.dom.java.Interface;
import org.mybatis.generator.api.dom.java.JavaVisibility;
import org.mybatis.generator.api.dom.java.Method;
import org.mybatis.generator.api.dom.java.Parameter;
Expand Down Expand Up @@ -167,6 +168,8 @@ public boolean modelExampleClassGenerated(TopLevelClass topLevelClass,
field.setVisibility(JavaVisibility.PROTECTED);
topLevelClass.addField(field);



method = new Method();
method.setName("setGroupSelClause");
method.setVisibility(JavaVisibility.PUBLIC);
Expand All @@ -183,6 +186,32 @@ public boolean modelExampleClassGenerated(TopLevelClass topLevelClass,
method.setReturnType(FullyQualifiedJavaType.getStringInstance());
method.addBodyLine(" return groupSelClause;");
topLevelClass.addMethod(method);


//--add for update
field = new Field();
field.setName("forUpdate");
field.setType(FullyQualifiedJavaType.getBooleanPrimitiveInstance());
field.setVisibility(JavaVisibility.PROTECTED);
topLevelClass.addField(field);

method = new Method();
method.setName("setForUpdate");
method.setVisibility(JavaVisibility.PUBLIC);
method.addParameter(new Parameter(FullyQualifiedJavaType
.getBooleanPrimitiveInstance(), "forUpdate"));
method.setReturnType(null);
method.addBodyLine(" this.forUpdate = forUpdate;");

topLevelClass.addMethod(method);

method = new Method();
method.setName("isForUpdate");
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getBooleanPrimitiveInstance());
method.addBodyLine(" return forUpdate;");
topLevelClass.addMethod(method);
//=----

field = new Field();
field.setName("groupByClause");
Expand Down Expand Up @@ -214,6 +243,8 @@ public boolean modelExampleClassGenerated(TopLevelClass topLevelClass,
mod.addBodyLine("this.sumCol=null;");
mod.addBodyLine("this.groupSelClause=null;");
mod.addBodyLine("this.groupByClause=null;");
mod.addBodyLine("this.forUpdate=false;");

}
String examplename = introspectedTable.getExampleType().substring(
introspectedTable.getExampleType().lastIndexOf(".") + 1);
Expand All @@ -225,12 +256,14 @@ public boolean modelExampleClassGenerated(TopLevelClass topLevelClass,
return true;
}


@Override
public boolean providerGenerated(TopLevelClass topLevelClass,
IntrospectedTable introspectedTable) {
// TODO providerGenerated
String tableName = introspectedTable.getTableConfiguration()
.getTableName();

// ----------------truncate provider---------------
// Method method = new Method();
// method.setName("truncate");
Expand All @@ -242,6 +275,25 @@ public boolean providerGenerated(TopLevelClass topLevelClass,
return true;
}


@Override
public boolean clientSelectByPrimaryKeyMethodGenerated(Method method,
Interface interfaze, IntrospectedTable introspectedTable) {
// TODO Auto-generated method stub
return super.clientSelectByPrimaryKeyMethodGenerated(method, interfaze,
introspectedTable);
}


@Override
public boolean clientSelectByPrimaryKeyMethodGenerated(Method method,
TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
// TODO Auto-generated method stub
return super.clientSelectByPrimaryKeyMethodGenerated(method, topLevelClass,
introspectedTable);
}


@Override
public boolean providerSelectByExampleWithBLOBsMethodGenerated(
Method method, TopLevelClass topLevelClass,
Expand Down Expand Up @@ -286,12 +338,15 @@ public boolean providerSelectByExampleWithoutBLOBsMethodGenerated(
"\t\t}");

line.add("if(example != null){");
line.add("return SQL().concat(\" limit \"+example.getOffset()+\",\"+example.getLimit());");

line.add("String retstr= SQL().concat(\" limit \"+example.getOffset()+\",\"+example.getLimit());");

// line.add("return \"SELECT * FROM (SELECT A.*, ROWNUM RN FROM (\"+SQL()+\") A WHERE ROWNUM < \"+(example.getLimit()+example.getOffset())+\") WHERE RN >= \"+(example.getOffset()) ;");

// line.add("return \"SELECT * FROM (SELECT A.*, rownumber() over() as RN FROM (\"+SQL()+\") A ) WHERE RN < \"+(example.getLimit()+example.getOffset())+\" AND RN >= \"+(example.getOffset()) ;");

line.add("if(example.isForUpdate()) { return retstr+\" FOR UPDATE \" ;} else { return retstr;}");

line.add("}");
int linesNumber = method.getBodyLines().size();
method.addBodyLines(linesNumber - 1, line);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public TSysAction selectOneByExample(TSysActionExample example)
@Override
//@Transactional
public int batchInsert(List<TSysAction> records) throws Exception {
if(records.size()<=0)return 0;
SqlSession session=sqlSessionFactory.openSession();
Connection conn = session.getConnection();
Statement st = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public TSysBranch selectOneByExample(TSysBranchExample example)
@Override
//@Transactional
public int batchInsert(List<TSysBranch> records) throws Exception {
if(records.size()<=0)return 0;
SqlSession session=sqlSessionFactory.openSession();
Connection conn = session.getConnection();
Statement st = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public TSysBusiness selectOneByExample(TSysBusinessExample example)
@Override
//@Transactional
public int batchInsert(List<TSysBusiness> records) throws Exception {
if(records.size()<=0)return 0;
SqlSession session=sqlSessionFactory.openSession();
Connection conn = session.getConnection();
Statement st = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public TSysMenu selectOneByExample(TSysMenuExample example)
@Override
//@Transactional
public int batchInsert(List<TSysMenu> records) throws Exception {
if(records.size()<=0)return 0;
SqlSession session=sqlSessionFactory.openSession();
Connection conn = session.getConnection();
Statement st = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public TSysOpLogs selectOneByExample(TSysOpLogsExample example)
@Override
//@Transactional
public int batchInsert(List<TSysOpLogs> records) throws Exception {
if(records.size()<=0)return 0;
SqlSession session=sqlSessionFactory.openSession();
Connection conn = session.getConnection();
Statement st = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public TSysParam selectOneByExample(TSysParamExample example)
@Override
//@Transactional
public int batchInsert(List<TSysParam> records) throws Exception {
if(records.size()<=0)return 0;
SqlSession session=sqlSessionFactory.openSession();
Connection conn = session.getConnection();
Statement st = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public TSysRoleAction selectOneByExample(TSysRoleActionExample example)
@Override
//@Transactional
public int batchInsert(List<TSysRoleAction> records) throws Exception {
if(records.size()<=0)return 0;
SqlSession session=sqlSessionFactory.openSession();
Connection conn = session.getConnection();
Statement st = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public TSysRole selectOneByExample(TSysRoleExample example)
@Override
//@Transactional
public int batchInsert(List<TSysRole> records) throws Exception {
if(records.size()<=0)return 0;
SqlSession session=sqlSessionFactory.openSession();
Connection conn = session.getConnection();
Statement st = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public TSysRoleMenu selectOneByExample(TSysRoleMenuExample example)
@Override
//@Transactional
public int batchInsert(List<TSysRoleMenu> records) throws Exception {
if(records.size()<=0)return 0;
SqlSession session=sqlSessionFactory.openSession();
Connection conn = session.getConnection();
Statement st = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public TSysRoleMutex selectOneByExample(TSysRoleMutexExample example)
@Override
//@Transactional
public int batchInsert(List<TSysRoleMutex> records) throws Exception {
if(records.size()<=0)return 0;
SqlSession session=sqlSessionFactory.openSession();
Connection conn = session.getConnection();
Statement st = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public TSysRspCode selectOneByExample(TSysRspCodeExample example)
@Override
//@Transactional
public int batchInsert(List<TSysRspCode> records) throws Exception {
if(records.size()<=0)return 0;
SqlSession session=sqlSessionFactory.openSession();
Connection conn = session.getConnection();
Statement st = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public TSysUser selectOneByExample(TSysUserExample example)
@Override
//@Transactional
public int batchInsert(List<TSysUser> records) throws Exception {
if(records.size()<=0)return 0;
SqlSession session=sqlSessionFactory.openSession();
Connection conn = session.getConnection();
Statement st = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public TSysUserRole selectOneByExample(TSysUserRoleExample example)
@Override
//@Transactional
public int batchInsert(List<TSysUserRole> records) throws Exception {
if(records.size()<=0)return 0;
SqlSession session=sqlSessionFactory.openSession();
Connection conn = session.getConnection();
Statement st = null;
Expand Down
Loading

0 comments on commit 7dc0a71

Please sign in to comment.