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("(");