public static MyTable getTableByTableName(String tableName,Connection conn){
return getTableByTableName(tableName, conn,true);
}
@SuppressWarnings("unchecked")
public static MyTable getTableByTableName(String tableName,Connection conn,boolean autoClose){
MyTable table=(MyTable) tableMap.get(tableName.toUpperCase());
if(table!=null){
return table;
}
//判断是否是懒加载
if(!isLazy){//如果不是懒加载,又找不到就报错
throw new RuntimeException("找不到该表名对应的表:"+tableName);
}else{//如果是懒加载则取当前MyTable
BuildMyTableForCommon builder=new BuildMyTableForCommon(conn);
builder.setAutoClose(autoClose);
table=builder.getMyTable(tableName);
if(table!=null){
tableMap.put(table.getTableName().toUpperCase(), table);//放入缓存
return table;
}
throw new RuntimeException("找不到该表名对应的表:"+tableName);
}