利用反射解决171兼容检查不通过问题

This commit is contained in:
makejava 2021-08-30 16:14:09 +08:00
parent 1b10a56226
commit 3d429faf57
1 changed files with 6 additions and 2 deletions

View File

@ -7,6 +7,8 @@ import com.intellij.psi.PsiClass;
import com.sjhy.plugin.entity.TableInfo;
import lombok.Data;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@ -36,8 +38,10 @@ public class TableInfoSettingsDTO {
builder.insert(0, ".");
}
builder.insert(0, name);
element = (DbElement) element.getParent();
if (element == null) {
try {
Method method = element.getClass().getDeclaredMethod("getParent");
element = (DbElement) method.invoke(element);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
break;
}
// 未必所有的数据库都是存在三层例如MySQL就只有两层如果上次层不是Namespace则不再继续获取