本文整理匯總了Java中tk.mybatis.mapper.entity.IDynamicTableName類的典型用法代碼示例。如果您正苦於以下問題:Java IDynamicTableName類的具體用法?Java IDynamicTableName怎麽用?Java IDynamicTableName使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IDynamicTableName類屬於tk.mybatis.mapper.entity包,在下文中一共展示了IDynamicTableName類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDynamicTableName
import tk.mybatis.mapper.entity.IDynamicTableName; //導入依賴的package包/類
/**
* 獲取表名 - 支持動態表名,該方法用於多個入參時,通過parameterName指定入參中實體類的@Param的注解值
*
* @param entityClass
* @param tableName
* @param parameterName
* @return
*/
public static String getDynamicTableName(Class<?> entityClass, String tableName, String parameterName) {
if (IDynamicTableName.class.isAssignableFrom(entityClass)) {
if (StringUtil.isNotEmpty(parameterName)) {
return "<if test=\"@[email protected](" + parameterName + ") and " + parameterName + ".dynamicTableName != null and " + parameterName + ".dynamicTableName != ''\">\n" +
"${" + parameterName + ".dynamicTableName}\n" +
"</if>\n" +
"<if test=\"@[email protected](" + parameterName + ") or " + parameterName + ".dynamicTableName == null or " + parameterName + ".dynamicTableName == ''\">\n" +
tableName + "\n" +
"</if>";
} else {
return getDynamicTableName(entityClass, tableName);
}
} else {
return tableName;
}
}
示例2: getDynamicTableName
import tk.mybatis.mapper.entity.IDynamicTableName; //導入依賴的package包/類
/**
* 獲取表名 - 支持動態表名
*
* @param entityClass
* @param tableName
* @return
*/
public static String getDynamicTableName(Class<?> entityClass, String tableName) {
if (IDynamicTableName.class.isAssignableFrom(entityClass)) {
StringBuilder sql = new StringBuilder();
sql.append("<choose>");
sql.append("<when test=\"@[email protected](_parameter) and dynamicTableName != null and dynamicTableName != ''\">");
sql.append("${dynamicTableName}\n");
sql.append("</when>");
//不支持指定列的時候查詢全部列
sql.append("<otherwise>");
sql.append(tableName);
sql.append("</otherwise>");
sql.append("</choose>");
return sql.toString();
} else {
return tableName;
}
}
示例3: getDynamicTableNameNode
import tk.mybatis.mapper.entity.IDynamicTableName; //導入依賴的package包/類
/**
* 獲取表名 - 支持動態表名
*
* @param entityClass
* @return
* @deprecated 4.x版本會移除該方法
*/
@Deprecated
protected SqlNode getDynamicTableNameNode(Class<?> entityClass) {
if (IDynamicTableName.class.isAssignableFrom(entityClass)) {
List<SqlNode> ifSqlNodes = new ArrayList<SqlNode>();
ifSqlNodes.add(new IfSqlNode(new TextSqlNode("${dynamicTableName}"), "@[email protected](_parameter) and dynamicTableName != null and dynamicTableName != ''"));
ifSqlNodes.add(new IfSqlNode(new StaticTextSqlNode(tableName(entityClass)), "@[email protected](_parameter) or dynamicTableName == null or dynamicTableName == ''"));
return new MixedSqlNode(ifSqlNodes);
} else {
return new StaticTextSqlNode(tableName(entityClass));
}
}
示例4: isDynamicParameter
import tk.mybatis.mapper.entity.IDynamicTableName; //導入依賴的package包/類
/**
* 判斷參數是否支持動態表名
*
* @param parameter
* @return true支持,false不支持
*/
public static boolean isDynamicParameter(Object parameter) {
if (parameter != null && parameter instanceof IDynamicTableName) {
return true;
}
return false;
}