Package org.jboss.as.cmp.jdbc.metadata

Examples of org.jboss.as.cmp.jdbc.metadata.JDBCMappingMetaData


        return metaData;
    }

    private static JDBCMappingMetaData parseMapping(final XMLStreamReader reader) throws XMLStreamException {

        final JDBCMappingMetaData metaData = new JDBCMappingMetaData();
        for (Element element : children(reader)) {
            switch (element) {
                case JAVA_TYPE: {
                    metaData.setJavaType(getElementText(reader));
                    break;
                }
                case JDBC_TYPE: {
                    metaData.setJdbcType(getJdbcTypeFromName(getElementText(reader)));
                    break;
                }
                case SQL_TYPE: {
                    metaData.setSqlType(getElementText(reader));
                    break;
                }
                case PARAM_SETTER: {
                    metaData.setParamSetter(getElementText(reader));
                    break;
                }
                case RESULT_READER: {
                    metaData.setResultReader(getElementText(reader));
                    break;
                }
                default: {
                    throw unexpectedElement(reader);
                }
View Full Code Here


        return metaData;
    }

    private static JDBCMappingMetaData parseMapping(final XMLStreamReader reader) throws XMLStreamException {

        final JDBCMappingMetaData metaData = new JDBCMappingMetaData();
        for (Element element : children(reader)) {
            switch (element) {
                case JAVA_TYPE: {
                    metaData.setJavaType(getElementText(reader));
                    break;
                }
                case JDBC_TYPE: {
                    metaData.setJdbcType(getJdbcTypeFromName(getElementText(reader)));
                    break;
                }
                case SQL_TYPE: {
                    metaData.setSqlType(getElementText(reader));
                    break;
                }
                case PARAM_SETTER: {
                    metaData.setParamSetter(getElementText(reader));
                    break;
                }
                case RESULT_READER: {
                    metaData.setResultReader(getElementText(reader));
                    break;
                }
                default: {
                    throw unexpectedElement(reader);
                }
View Full Code Here

            complexTypes.put(valueClass.getJavaType(), type);
        }

        Iterator i = typeMapping.getMappings().iterator();
        while (i.hasNext()) {
            JDBCMappingMetaData mapping = (JDBCMappingMetaData) i.next();

            String sqlType = mapping.getSqlType();
            int jdbcType = mapping.getJdbcType();
            Class javaType = loadClass(mapping.getJavaType());
            boolean notNull = javaType.isPrimitive();
            boolean autoIncrement = false;

            JDBCParameterSetter paramSetter;
            if (mapping.getParamSetter() != null) {
                paramSetter = (JDBCParameterSetter) newInstance(mapping.getParamSetter());
            } else {
                paramSetter = JDBCUtil.getParameterSetter(jdbcType, javaType);
            }

            JDBCResultSetReader resultReader;
            if (mapping.getResultReader() != null) {
                resultReader = (JDBCResultSetReader) newInstance(mapping.getResultReader());
            } else {
                resultReader = JDBCUtil.getResultSetReader(jdbcType, javaType);
            }

            JDBCTypeSimple type = new JDBCTypeSimple(
View Full Code Here

                    } catch (Throwable e) {
                        throw new IllegalStateException("Failed to create Mapper instance of " + userTypeMapping.getMapper());
                    }
                }

                JDBCMappingMetaData typeMappingMD = typeMapping.getTypeMappingMetaData(javaType);
                String sqlType = typeMappingMD.getSqlType();
                int jdbcType = typeMappingMD.getJdbcType();
                boolean notNull = javaType.isPrimitive();
                boolean autoIncrement = false;

                JDBCParameterSetter paramSetter;
                if (typeMappingMD.getParamSetter() != null) {
                    try {
                        paramSetter = (JDBCParameterSetter) newInstance(typeMappingMD.getParamSetter());
                    } catch (Throwable e) {
                        throw new IllegalStateException(e.getMessage());
                    }
                } else {
                    paramSetter = JDBCUtil.getParameterSetter(jdbcType, javaType);
                }

                JDBCResultSetReader resultReader;
                if (typeMappingMD.getResultReader() != null) {
                    try {
                        resultReader = (JDBCResultSetReader) newInstance(typeMappingMD.getResultReader());
                    } catch (Throwable e) {
                        throw new IllegalStateException(e.getMessage());
                    }
                } else {
                    resultReader = JDBCUtil.getResultSetReader(jdbcType, javaType);
View Full Code Here

    private JDBCTypeSimple createTypeSimple(JDBCCMPFieldMetaData cmpField) {
        String columnName = cmpField.getColumnName();
        Class javaType = cmpField.getFieldType();

        JDBCMappingMetaData typeMappingMD = typeMapping.getTypeMappingMetaData(javaType);
        String paramSetter = typeMappingMD.getParamSetter();
        String resultReader = typeMappingMD.getResultReader();

        int jdbcType;
        String sqlType = cmpField.getSQLType();
        if (sqlType != null) {
            jdbcType = cmpField.getJDBCType();
        } else {
            // get jdbcType and sqlType from typeMapping
            sqlType = typeMappingMD.getSqlType();
            jdbcType = typeMappingMD.getJdbcType();
        }

        boolean notNull = cmpField.isNotNull();
        boolean autoIncrement = cmpField.isAutoIncrement();

        Mapper mapper = null;
        JDBCUserTypeMappingMetaData userTypeMapping = (JDBCUserTypeMappingMetaData) userTypeMappings.get(javaType.getName());
        if (userTypeMapping != null) {
            String mappedTypeStr = userTypeMapping.getMappedType();
            try {
                final ClassLoader contextClassLoader = TCLAction.UTIL.getContextClassLoader();
                Class mapperClass = contextClassLoader.loadClass(userTypeMapping.getMapper());
                mapper = (Mapper) mapperClass.newInstance();
                javaType = contextClassLoader.loadClass(mappedTypeStr);
                if (cmpField.getSQLType() == null) {
                    JDBCMappingMetaData mappingMD = typeMapping.getTypeMappingMetaData(javaType);
                    sqlType = mappingMD.getSqlType();
                    jdbcType = mappingMD.getJdbcType();
                    paramSetter = mappingMD.getParamSetter();
                    resultReader = mappingMD.getResultReader();
                }
            } catch (ClassNotFoundException e) {
                throw new RuntimeException("Class not found for mapper: " + userTypeMapping.getMapper(), e);
            } catch (Exception e) {
                throw new RuntimeException("Could not instantiate mapper: " + userTypeMapping.getMapper(), e);
View Full Code Here

            int jdbcType;
            if (sqlType != null) {
                jdbcType = propertyMetaData.getJDBCType();
            } else {
                // get jdbcType and sqlType from typeMapping
                JDBCMappingMetaData typeMappingMD = typeMapping.getTypeMappingMetaData(javaType);
                sqlType = typeMappingMD.getSqlType();
                jdbcType = typeMappingMD.getJdbcType();
            }

            boolean notNull = propertyStack.isNotNull();

            Method[] getters = propertyStack.getGetters();
View Full Code Here

        return metaData;
    }

    private static JDBCMappingMetaData parseMapping(final XMLStreamReader reader) throws XMLStreamException {

        final JDBCMappingMetaData metaData = new JDBCMappingMetaData();
        for (Element element : children(reader)) {
            switch (element) {
                case JAVA_TYPE: {
                    metaData.setJavaType(getElementText(reader));
                    break;
                }
                case JDBC_TYPE: {
                    metaData.setJdbcType(getJdbcTypeFromName(getElementText(reader)));
                    break;
                }
                case SQL_TYPE: {
                    metaData.setSqlType(getElementText(reader));
                    break;
                }
                case PARAM_SETTER: {
                    metaData.setParamSetter(getElementText(reader));
                    break;
                }
                case RESULT_READER: {
                    metaData.setResultReader(getElementText(reader));
                    break;
                }
                default: {
                    throw unexpectedElement(reader);
                }
View Full Code Here

            complexTypes.put(valueClass.getJavaType(), type);
        }

        Iterator i = typeMapping.getMappings().iterator();
        while (i.hasNext()) {
            JDBCMappingMetaData mapping = (JDBCMappingMetaData) i.next();

            String sqlType = mapping.getSqlType();
            int jdbcType = mapping.getJdbcType();
            Class javaType = loadClass(mapping.getJavaType());
            boolean notNull = javaType.isPrimitive();
            boolean autoIncrement = false;

            JDBCParameterSetter paramSetter;
            if (mapping.getParamSetter() != null) {
                paramSetter = (JDBCParameterSetter) newInstance(mapping.getParamSetter());
            } else {
                paramSetter = JDBCUtil.getParameterSetter(jdbcType, javaType);
            }

            JDBCResultSetReader resultReader;
            if (mapping.getResultReader() != null) {
                resultReader = (JDBCResultSetReader) newInstance(mapping.getResultReader());
            } else {
                resultReader = JDBCUtil.getResultSetReader(jdbcType, javaType);
            }

            JDBCTypeSimple type = new JDBCTypeSimple(
View Full Code Here

                    } catch (Throwable t) {
                        throw MESSAGES.failedToLoadMapperInstance(userTypeMapping.getMapper(), t);
                    }
                }

                JDBCMappingMetaData typeMappingMD = typeMapping.getTypeMappingMetaData(javaType);
                String sqlType = typeMappingMD.getSqlType();
                int jdbcType = typeMappingMD.getJdbcType();
                boolean notNull = javaType.isPrimitive();
                boolean autoIncrement = false;

                JDBCParameterSetter paramSetter;
                if (typeMappingMD.getParamSetter() != null) {
                    try {
                        paramSetter = (JDBCParameterSetter) newInstance(typeMappingMD.getParamSetter());
                    } catch (Throwable e) {
                        throw MESSAGES.failedToCreateParamSetter(typeMappingMD.getParamSetter(), e);
                    }
                } else {
                    paramSetter = JDBCUtil.getParameterSetter(jdbcType, javaType);
                }

                JDBCResultSetReader resultReader;
                if (typeMappingMD.getResultReader() != null) {
                    try {
                        resultReader = (JDBCResultSetReader) newInstance(typeMappingMD.getResultReader());
                    } catch (Throwable e) {
                        throw MESSAGES.failedToCreateResultReader(typeMappingMD.getResultReader(), e);
                    }
                } else {
                    resultReader = JDBCUtil.getResultSetReader(jdbcType, javaType);
                }
View Full Code Here

    private JDBCTypeSimple createTypeSimple(JDBCCMPFieldMetaData cmpField) {
        String columnName = cmpField.getColumnName();
        Class javaType = cmpField.getFieldType();

        JDBCMappingMetaData typeMappingMD = typeMapping.getTypeMappingMetaData(javaType);
        String paramSetter = typeMappingMD.getParamSetter();
        String resultReader = typeMappingMD.getResultReader();

        int jdbcType;
        String sqlType = cmpField.getSQLType();
        if (sqlType != null) {
            jdbcType = cmpField.getJDBCType();
        } else {
            // get jdbcType and sqlType from typeMapping
            sqlType = typeMappingMD.getSqlType();
            jdbcType = typeMappingMD.getJdbcType();
        }

        boolean notNull = cmpField.isNotNull();
        boolean autoIncrement = cmpField.isAutoIncrement();

        Mapper mapper = null;
        JDBCUserTypeMappingMetaData userTypeMapping = (JDBCUserTypeMappingMetaData) userTypeMappings.get(javaType.getName());
        if (userTypeMapping != null) {
            String mappedTypeStr = userTypeMapping.getMappedType();
            try {
                final ClassLoader contextClassLoader = TCLAction.UTIL.getContextClassLoader();
                Class mapperClass = contextClassLoader.loadClass(userTypeMapping.getMapper());
                mapper = (Mapper) mapperClass.newInstance();
                javaType = contextClassLoader.loadClass(mappedTypeStr);
                if (cmpField.getSQLType() == null) {
                    JDBCMappingMetaData mappingMD = typeMapping.getTypeMappingMetaData(javaType);
                    sqlType = mappingMD.getSqlType();
                    jdbcType = mappingMD.getJdbcType();
                    paramSetter = mappingMD.getParamSetter();
                    resultReader = mappingMD.getResultReader();
                }
            } catch (ClassNotFoundException e) {
                throw MESSAGES.couldNotCreateTypeMapper(userTypeMapping.getMapper(), e);
            } catch (Exception e) {
                throw MESSAGES.couldNotCreateTypeMapper(userTypeMapping.getMapper(), e);
View Full Code Here

TOP

Related Classes of org.jboss.as.cmp.jdbc.metadata.JDBCMappingMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.