public class MarkdownClasspathLoader extends AbstractClassPathSQLLoader
selectUser === select * from user
可以重载此类,实现#getParser 用于解析其他格式文件,比如xml格式的sql文件
| 限定符和类型 | 类和说明 |
|---|---|
static class |
MarkdownClasspathLoader.SQLFileVersion
记录sql的版本号,如果为0,表示无版本,比如md文件在jar里
|
| 限定符和类型 | 字段和说明 |
|---|---|
protected String |
charset |
protected SQLSource |
EMPTY |
protected String |
sqlRoot |
protected Map<SqlId,SQLSource> |
sqlSourceMap
外部sql缓存
|
classLoaderKitautoGenSourceMap, dbs, product| 构造器和说明 |
|---|
MarkdownClasspathLoader() |
MarkdownClasspathLoader(String root) |
MarkdownClasspathLoader(String root,
String charset) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected BufferedReader |
buildBufferedReader(InputStream inputStream,
String charset)
子类覆盖,可以用于加密文件的解密
|
boolean |
existExternalSource(SqlId id) |
boolean |
existNamespace(SqlId id)
检测是否存在sqlId的namespace,如文件
|
String |
getCharset() |
protected URL |
getDBRootFile(SqlId id) |
protected URL |
getFilePath(String root,
SqlId id) |
protected SQLFileParser |
getParser(String modelName,
BufferedReader br) |
protected URL |
getRootFile(SqlId id)
获取.md文件
md文件需放在classpath下
|
String |
getSqlRoot() |
protected Long |
getURLVersion(URL url) |
boolean |
isExternalSourceModified(SqlId id)
比较sql是否变化,比较sql所在的文件是否变化,如果变化,则认为sql变化,提示beetl重新解析sql语句
|
protected void |
loadFromClassPath(SqlId id)
考虑到跨数据库支持,ClasspathLoader加载SQL顺序如下:
首先根据DBStyle.getName() 找到对应的数据库名称,然后在ROOT/dbName 下找对应的sql,
如果ROOT/dbName 文件目录不存在,或者相应的sql文件不存在,再搜索ROOT目录下的sql文件。
|
SQLSource |
queryExternalSource(SqlId id) |
protected void |
readSqlFile(SqlId sqlId,
URL url,
boolean isRoot) |
void |
refresh() |
void |
removeExternalSource(SqlId id) |
void |
setCharset(String charset) |
void |
setSqlRoot(String sqlRoot) |
String |
toString() |
getClassLoaderKit, getException, setClassLoaderKitaddSQL, exist, getDbStyle, getPathBySqlId, isModified, isProduct, queryAutoSQL, querySQL, setDbStyle, setProductprotected String sqlRoot
protected String charset
protected SQLSource EMPTY
public MarkdownClasspathLoader(String root)
public MarkdownClasspathLoader()
public SQLSource queryExternalSource(SqlId id)
queryExternalSource 在类中 AbstractSQLLoaderpublic boolean existExternalSource(SqlId id)
existExternalSource 在类中 AbstractSQLLoaderpublic boolean isExternalSourceModified(SqlId id)
isExternalSourceModified 在类中 AbstractSQLLoaderid - public void removeExternalSource(SqlId id)
removeExternalSource 在类中 AbstractSQLLoaderprotected void loadFromClassPath(SqlId id)
public boolean existNamespace(SqlId id)
SQLLoaderprotected SQLFileParser getParser(String modelName, BufferedReader br) throws IOException
IOExceptionprotected BufferedReader buildBufferedReader(InputStream inputStream, String charset)
inputStream - charset - public String getSqlRoot()
public void setSqlRoot(String sqlRoot)
public String getCharset()
public void setCharset(String charset)
public void refresh()
refresh 在接口中 SQLLoaderrefresh 在类中 AbstractSQLLoaderCopyright © 2022. All rights reserved.