org.mybatis.generator.api.JavaTypeResolver Java Examples

The following examples show how to use org.mybatis.generator.api.JavaTypeResolver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectFactory.java    From mybatis-generator-plus with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: DatabaseIntrospector.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
public DatabaseIntrospector(Context context,
        DatabaseMetaData databaseMetaData,
        JavaTypeResolver javaTypeResolver, List<String> warnings) {
    super();
    this.context = context;
    this.databaseMetaData = databaseMetaData;
    this.javaTypeResolver = javaTypeResolver;
    this.warnings = warnings;
    logger = LogFactory.getLog(getClass());
}
 
Example #3
Source File: ObjectFactory.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #4
Source File: DatabaseIntrospector.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
public DatabaseIntrospector(Context context,
        DatabaseMetaData databaseMetaData,
        JavaTypeResolver javaTypeResolver, List<String> warnings) {
    super();
    this.context = context;
    this.databaseMetaData = databaseMetaData;
    this.javaTypeResolver = javaTypeResolver;
    this.warnings = warnings;
    logger = LogFactory.getLog(getClass());
}
 
Example #5
Source File: Context.java    From mapper-generator-javafx with Apache License 2.0 4 votes vote down vote up
/**
 * 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<>();
    JavaTypeResolver javaTypeResolver = ObjectFactory.createJavaTypeResolver(this, warnings);

    Connection connection = null;

    try {
        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.isEmpty()
                    && !fullyQualifiedTableNames.contains(tableName)) {
                continue;
            }

            if (!tc.areAnyStatementsEnabled()) {
                warnings.add(getString("Warning.0", tableName));
                continue;
            }

            callback.startTask(getString("Progress.1", tableName));
            List<IntrospectedTable> tables = databaseIntrospector.introspectTables(tc);

            if (tables != null) {
                introspectedTables.addAll(tables);
            }

            callback.checkCancel();
        }
    } finally {
        closeConnection(connection);
    }
}
 
Example #6
Source File: Context.java    From mybatis-generator-core-fix with Apache License 2.0 4 votes vote down vote up
/**
 * 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 {
        callback.startTask(getString("Progress.0")); //$NON-NLS-1$
        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) {
                if (!fullyQualifiedTableNames.contains(tableName)) {
                    continue;
                }
            }

            if (!tc.areAnyStatementsEnabled()) {
                warnings.add(getString("Warning.0", tableName)); //$NON-NLS-1$
                continue;
            }

            callback.startTask(getString("Progress.1", tableName)); //$NON-NLS-1$
            List<IntrospectedTable> tables = databaseIntrospector
                    .introspectTables(tc);

            if (tables != null) {
                introspectedTables.addAll(tables);
            }

            callback.checkCancel();
        }
    } finally {
        closeConnection(connection);
    }
}
 
Example #7
Source File: Context.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
/**
 * 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 {
		callback.startTask(getString("Progress.0")); //$NON-NLS-1$
		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) {
				if (!fullyQualifiedTableNames.contains(tableName)) {
					continue;
				}
			}

			if (!tc.areAnyStatementsEnabled()) {
				warnings.add(getString("Warning.0", tableName)); //$NON-NLS-1$
				continue;
			}

			callback.startTask(getString("Progress.1", tableName)); //$NON-NLS-1$
			List<IntrospectedTable> tables = databaseIntrospector.introspectTables(tc);

			if (tables != null) {
				introspectedTables.addAll(tables);
			}

			callback.checkCancel();
		}
	}
	finally {
		closeConnection(connection);
	}
}
 
Example #8
Source File: DatabaseIntrospector.java    From mybatis-generator-core-fix with Apache License 2.0 3 votes vote down vote up
/**
 * Instantiates a new database introspector.
 *
 * @param context
 *            the context
 * @param databaseMetaData
 *            the database meta data
 * @param javaTypeResolver
 *            the java type resolver
 * @param warnings
 *            the warnings
 */
public DatabaseIntrospector(Context context,
        DatabaseMetaData databaseMetaData,
        JavaTypeResolver javaTypeResolver, List<String> warnings) {
    super();
    this.context = context;
    this.databaseMetaData = databaseMetaData;
    this.javaTypeResolver = javaTypeResolver;
    this.warnings = warnings;
    logger = LogFactory.getLog(getClass());
}