From 1e56db8fe6d53d0fbb2429b5f8e464030348a9a4 Mon Sep 17 00:00:00 2001 From: qi_liang Date: Mon, 20 May 2019 15:09:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/panda/jdbc/sql/AbstractDbBuiler.java | 1 - .../src/main/java/org/panda/jdbc/sql/BeanSqlUtil.java | 8 +++++--- .../src/main/java/org/panda/jdbc/sql/MysqlBuilder.java | 8 +++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/panda-jdbc/src/main/java/org/panda/jdbc/sql/AbstractDbBuiler.java b/panda-jdbc/src/main/java/org/panda/jdbc/sql/AbstractDbBuiler.java index 0944419..308f510 100644 --- a/panda-jdbc/src/main/java/org/panda/jdbc/sql/AbstractDbBuiler.java +++ b/panda-jdbc/src/main/java/org/panda/jdbc/sql/AbstractDbBuiler.java @@ -93,7 +93,6 @@ public abstract class AbstractDbBuiler { sql=sql.toLowerCase(); if (sql.lastIndexOf("order")>sql.lastIndexOf(")")){ sb.append(sql.substring(sql.indexOf("from")+4,sql.lastIndexOf("order"))); - }else{ sb.append(sql.substring(sql.indexOf("from")+4)); } diff --git a/panda-jdbc/src/main/java/org/panda/jdbc/sql/BeanSqlUtil.java b/panda-jdbc/src/main/java/org/panda/jdbc/sql/BeanSqlUtil.java index 19e341a..c75c293 100644 --- a/panda-jdbc/src/main/java/org/panda/jdbc/sql/BeanSqlUtil.java +++ b/panda-jdbc/src/main/java/org/panda/jdbc/sql/BeanSqlUtil.java @@ -15,6 +15,8 @@ import java.util.Map; */ public class BeanSqlUtil { + public static final String SQL_CHARACTER = "_"; + /** * 大小写转化驼峰 * @param str @@ -23,13 +25,13 @@ public class BeanSqlUtil { public static String caseToHump(String str){ StringBuffer strBuffer=new StringBuffer(); char[] charArray=str.toCharArray(); - for (int i=0;i{ sql.append(createTableStr(value)); }); - - return sql.toString(); } @@ -122,7 +119,7 @@ public class MysqlBuilder extends AbstractDbBuiler { sql.append(","); } sql.append("primary key(id)"); - sql.append(")ENGINE=MyISAM DEFAULT CHARSET=utf8;"); + sql.append(")ENGINE=Innodb DEFAULT CHARSET=utf8;"); return sql.toString(); } @@ -139,7 +136,8 @@ public class MysqlBuilder extends AbstractDbBuiler { if (CollectionUtil.isEmpty(fieldMap)){ LOGGER.error("can not insert entity:fieldMap is empty"); - return null; + throw new RuntimeException("can not insert entity:fieldMap is empty"); + // return null; } String sql = "INSERT INTO "+ BeanSqlUtil.beanNameToTableName(entityClass); StringBuilder columns = new StringBuilder("(");