<!-- The javaTypeResolver element is used to define properties of the Java Type Resolver. The Java Type Resolver is used to calculate Java types from database column information. The default Java Type Resolver attempts to make JDBC DECIMAL and NUMERIC types easier to use by substituting Integral types if possible (Long, Integer, Short, etc.) --> <!ELEMENT javaTypeResolver (property*)> <!ATTLIST javaTypeResolver typeCDATA#IMPLIED>
publicJavaTypeResolverDefaultImpl(){ super(); properties = new Properties(); typeMap = new HashMap<>();
typeMap.put(Types.ARRAY, new JdbcTypeInformation("ARRAY", //$NON-NLS-1$ new FullyQualifiedJavaType(Object.class.getName()))); typeMap.put(Types.BIGINT, new JdbcTypeInformation("BIGINT", //$NON-NLS-1$ new FullyQualifiedJavaType(Long.class.getName()))); typeMap.put(Types.BINARY, new JdbcTypeInformation("BINARY", //$NON-NLS-1$ new FullyQualifiedJavaType("byte[]"))); //$NON-NLS-1$ typeMap.put(Types.BIT, new JdbcTypeInformation("BIT", //$NON-NLS-1$ new FullyQualifiedJavaType(Boolean.class.getName()))); typeMap.put(Types.BLOB, new JdbcTypeInformation("BLOB", //$NON-NLS-1$ new FullyQualifiedJavaType("byte[]"))); //$NON-NLS-1$ typeMap.put(Types.BOOLEAN, new JdbcTypeInformation("BOOLEAN", //$NON-NLS-1$ new FullyQualifiedJavaType(Boolean.class.getName()))); typeMap.put(Types.CHAR, new JdbcTypeInformation("CHAR", //$NON-NLS-1$ new FullyQualifiedJavaType(String.class.getName()))); typeMap.put(Types.CLOB, new JdbcTypeInformation("CLOB", //$NON-NLS-1$ new FullyQualifiedJavaType(String.class.getName()))); typeMap.put(Types.DATALINK, new JdbcTypeInformation("DATALINK", //$NON-NLS-1$ new FullyQualifiedJavaType(Object.class.getName()))); typeMap.put(Types.DATE, new JdbcTypeInformation("DATE", //$NON-NLS-1$ new FullyQualifiedJavaType(Date.class.getName()))); typeMap.put(Types.DECIMAL, new JdbcTypeInformation("DECIMAL", //$NON-NLS-1$ new FullyQualifiedJavaType(BigDecimal.class.getName()))); typeMap.put(Types.DISTINCT, new JdbcTypeInformation("DISTINCT", //$NON-NLS-1$ new FullyQualifiedJavaType(Object.class.getName()))); typeMap.put(Types.DOUBLE, new JdbcTypeInformation("DOUBLE", //$NON-NLS-1$ new FullyQualifiedJavaType(Double.class.getName()))); typeMap.put(Types.FLOAT, new JdbcTypeInformation("FLOAT", //$NON-NLS-1$ new FullyQualifiedJavaType(Double.class.getName()))); typeMap.put(Types.INTEGER, new JdbcTypeInformation("INTEGER", //$NON-NLS-1$ new FullyQualifiedJavaType(Integer.class.getName()))); typeMap.put(Types.JAVA_OBJECT, new JdbcTypeInformation("JAVA_OBJECT", //$NON-NLS-1$ new FullyQualifiedJavaType(Object.class.getName()))); typeMap.put(Types.LONGNVARCHAR, new JdbcTypeInformation("LONGNVARCHAR", //$NON-NLS-1$ new FullyQualifiedJavaType(String.class.getName()))); typeMap.put(Types.LONGVARBINARY, new JdbcTypeInformation( "LONGVARBINARY", //$NON-NLS-1$ new FullyQualifiedJavaType("byte[]"))); //$NON-NLS-1$ typeMap.put(Types.LONGVARCHAR, new JdbcTypeInformation("LONGVARCHAR", //$NON-NLS-1$ new FullyQualifiedJavaType(String.class.getName()))); typeMap.put(Types.NCHAR, new JdbcTypeInformation("NCHAR", //$NON-NLS-1$ new FullyQualifiedJavaType(String.class.getName()))); typeMap.put(Types.NCLOB, new JdbcTypeInformation("NCLOB", //$NON-NLS-1$ new FullyQualifiedJavaType(String.class.getName()))); typeMap.put(Types.NVARCHAR, new JdbcTypeInformation("NVARCHAR", //$NON-NLS-1$ new FullyQualifiedJavaType(String.class.getName()))); typeMap.put(Types.NULL, new JdbcTypeInformation("NULL", //$NON-NLS-1$ new FullyQualifiedJavaType(Object.class.getName()))); typeMap.put(Types.NUMERIC, new JdbcTypeInformation("NUMERIC", //$NON-NLS-1$ new FullyQualifiedJavaType(BigDecimal.class.getName()))); typeMap.put(Types.OTHER, new JdbcTypeInformation("OTHER", //$NON-NLS-1$ new FullyQualifiedJavaType(Object.class.getName()))); typeMap.put(Types.REAL, new JdbcTypeInformation("REAL", //$NON-NLS-1$ new FullyQualifiedJavaType(Float.class.getName()))); typeMap.put(Types.REF, new JdbcTypeInformation("REF", //$NON-NLS-1$ new FullyQualifiedJavaType(Object.class.getName()))); typeMap.put(Types.SMALLINT, new JdbcTypeInformation("SMALLINT", //$NON-NLS-1$ new FullyQualifiedJavaType(Short.class.getName()))); typeMap.put(Types.STRUCT, new JdbcTypeInformation("STRUCT", //$NON-NLS-1$ new FullyQualifiedJavaType(Object.class.getName()))); typeMap.put(Types.TIME, new JdbcTypeInformation("TIME", //$NON-NLS-1$ new FullyQualifiedJavaType(Date.class.getName()))); typeMap.put(Types.TIMESTAMP, new JdbcTypeInformation("TIMESTAMP", //$NON-NLS-1$ new FullyQualifiedJavaType(Date.class.getName()))); typeMap.put(Types.TINYINT, new JdbcTypeInformation("TINYINT", //$NON-NLS-1$ new FullyQualifiedJavaType(Byte.class.getName()))); typeMap.put(Types.VARBINARY, new JdbcTypeInformation("VARBINARY", //$NON-NLS-1$ new FullyQualifiedJavaType("byte[]"))); //$NON-NLS-1$ typeMap.put(Types.VARCHAR, new JdbcTypeInformation("VARCHAR", //$NON-NLS-1$ new FullyQualifiedJavaType(String.class.getName()))); // JDK 1.8 types typeMap.put(Types.TIME_WITH_TIMEZONE, new JdbcTypeInformation("TIME_WITH_TIMEZONE", //$NON-NLS-1$ new FullyQualifiedJavaType("java.time.OffsetTime"))); //$NON-NLS-1$ typeMap.put(Types.TIMESTAMP_WITH_TIMEZONE, new JdbcTypeInformation("TIMESTAMP_WITH_TIMEZONE", //$NON-NLS-1$ new FullyQualifiedJavaType("java.time.OffsetDateTime"))); //$NON-NLS-1$ }
这个标签的作用是配置注释的生成规则,它的 DTD 如下,其中也有一个 type 属性,可以用来指定自定义配置类:
1 2 3 4 5 6 7
<!-- The commentGenerator element is used to define properties of the Comment Generator. The Comment Generator adds comments to generated elements. --> <!ELEMENT commentGenerator (property*)> <!ATTLIST commentGenerator typeCDATA#IMPLIED>