use of org.mybatis.generator.api.JavaTypeResolver in project generator by mybatis.
the class Context method introspectTables.
/**
* Introspect tables based on the configuration specified in the
* constructor. This method is long running.
*
* @param callback
* a progress callback if progress information is desired, or
* <code>null</code>
* @param warnings
* any warning generated from this method will be added to the
* List. Warnings are always Strings.
* @param fullyQualifiedTableNames
* a set of table names to generate. The elements of the set must
* be Strings that exactly match what's specified in the
* configuration. For example, if table name = "foo" and schema =
* "bar", then the fully qualified table name is "foo.bar". If
* the Set is null or empty, then all tables in the configuration
* will be used for code generation.
*
* @throws SQLException
* if some error arises while introspecting the specified
* database tables.
* @throws InterruptedException
* if the progress callback reports a cancel
*/
public void introspectTables(ProgressCallback callback, List<String> warnings, Set<String> fullyQualifiedTableNames) throws SQLException, InterruptedException {
introspectedTables = new ArrayList<IntrospectedTable>();
JavaTypeResolver javaTypeResolver = ObjectFactory.createJavaTypeResolver(this, warnings);
Connection connection = null;
try {
//$NON-NLS-1$
callback.startTask(getString("Progress.0"));
connection = getConnection();
DatabaseIntrospector databaseIntrospector = new DatabaseIntrospector(this, connection.getMetaData(), javaTypeResolver, warnings);
for (TableConfiguration tc : tableConfigurations) {
String tableName = composeFullyQualifiedTableName(tc.getCatalog(), tc.getSchema(), tc.getTableName(), '.');
if (fullyQualifiedTableNames != null && fullyQualifiedTableNames.size() > 0 && !fullyQualifiedTableNames.contains(tableName)) {
continue;
}
if (!tc.areAnyStatementsEnabled()) {
//$NON-NLS-1$
warnings.add(getString("Warning.0", tableName));
continue;
}
//$NON-NLS-1$
callback.startTask(getString("Progress.1", tableName));
List<IntrospectedTable> tables = databaseIntrospector.introspectTables(tc);
if (tables != null) {
introspectedTables.addAll(tables);
}
callback.checkCancel();
}
} finally {
closeConnection(connection);
}
}
use of org.mybatis.generator.api.JavaTypeResolver in project generator by mybatis.
the class ObjectFactory method createJavaTypeResolver.
/**
* Creates a new Object object.
*
* @param context
* the context
* @param warnings
* the warnings
* @return the java type resolver
*/
public static JavaTypeResolver createJavaTypeResolver(Context context, List<String> warnings) {
JavaTypeResolverConfiguration config = context.getJavaTypeResolverConfiguration();
String type;
if (config != null && config.getConfigurationType() != null) {
type = config.getConfigurationType();
if ("DEFAULT".equalsIgnoreCase(type)) {
//$NON-NLS-1$
type = JavaTypeResolverDefaultImpl.class.getName();
}
} else {
type = JavaTypeResolverDefaultImpl.class.getName();
}
JavaTypeResolver answer = (JavaTypeResolver) createInternalObject(type);
answer.setWarnings(warnings);
if (config != null) {
answer.addConfigurationProperties(config.getProperties());
}
answer.setContext(context);
return answer;
}
Aggregations