JpaEntityTableMetadataParser implements EntityTableMetadataParser { public Optional<RDBTableMetadata> parseTableMetadata(Class<?> entityType) { Table table = AnnotationUtils.getAnnotation(entityType, Table.class); if (table == null) { return Optional.empty(); } RDBSchemaMetadata schema = databaseMetadata.getSchema(table.schema()) .orElseGet(databaseMetadata::getCurrentSchema); RDBTableMetadata tableMetadata = schema.newTable(table.name()); Optional.ofNullable(ClassUtils.getAnnotation(entityType, Comment.class)) .map(Comment::value) .ifPresent(tableMetadata::setComment); JpaEntityTableMetadataParserProcessor parserProcessor = new JpaEntityTableMetadataParserProcessor(tableMetadata, entityType); parserProcessor.setDataTypeResolver(dataTypeResolver); parserProcessor.setValueCodecResolver(valueCodecResolver); parserProcessor.process(); return Optional.of(tableMetadata); }  Optional<RDBTableMetadata> parseTableMetadata(Class<?> entityType);  }
@Test public void test() { RDBDatabaseMetadata database = new RDBDatabaseMetadata(Dialect.H2); H2SchemaMetadata schema = new H2SchemaMetadata("PUBLIC"); database.setCurrentSchema(schema); database.addSchema(schema); JpaEntityTableMetadataParser parser = new JpaEntityTableMetadataParser(); parser.setDatabaseMetadata(database); RDBTableMetadata table = parser.parseTableMetadata(User.class).orElseThrow(IllegalArgumentException::new); Assert.assertEquals(table.getName(), "entity_test"); RDBColumnMetadata id = table.getColumn("id").orElseThrow(NullPointerException::new); Assert.assertTrue(id.isPrimaryKey()); Assert.assertEquals(id.getJavaType(), String.class); Assert.assertEquals(id.getLength(), 32); Assert.assertEquals(table.getColumn("create_time").orElseThrow(NullPointerException::new).getAlias(), "createTime"); }