An open API service indexing awesome lists of open source software.

https://github.com/pleuvoir/sql-metadata-plugin

Execute SQL to return result set metadata easily.
https://github.com/pleuvoir/sql-metadata-plugin

metadata plugin springframework sql

Last synced: 5 months ago
JSON representation

Execute SQL to return result set metadata easily.

Awesome Lists containing this project

README

          

# sql-metadata-plugin

Execute SQL to return result-set metadata easily. It also provide template engine support for code-generator.

[![HitCount](http://hits.dwyl.io/pleuvoir/sql-metadata-plugin.svg)](http://hits.dwyl.io/pleuvoir/sql-metadata-plugin)
[![GitHub issues](https://img.shields.io/github/issues/pleuvoir/sql-metadata-plugin.svg)](https://github.com/pleuvoir/sql-metadata-plugin/issues)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?label=license)](https://github.com/pleuvoir/sql-metadata-plugin/blob/master/LICENSE)
[![Maven Central](https://img.shields.io/maven-central/v/io.github.pleuvoir/sql-metadata-plugin.svg?label=maven%20central)](https://oss.sonatype.org/#nexus-search;quick~sql-metadata-plugin)
[![Download](https://img.shields.io/badge/downloads-master-green.svg)](https://codeload.github.com/pleuvoir/sql-metadata-plugin/zip/master)

## Usage

### import dependency

```xml

io.github.pleuvoir
sql-metadata-plugin
${latest.version}

```

### register in spring container

```xml









```

### junit test

```java
@Autowired
private DBScriptRunner dBScriptRunner;

@Test
public void contextTest() throws FileNotFoundException, IOException, TemplateException {

// 1. get metaData
MetaData metaData = dBScriptRunner.excute("select * from pub_param");

String entityName = "pubParamPO";

// 2. convert to dataModel
DataModel dataModel = metaData.asDataModel().addData("entityName", entityName);

System.out.println(dataModel.toJSON());

// 3. write file ..
dataModel.write("po.ftl", "D:\\" + entityName + ".java");
}
```

you can realize your TypeHandlerFactory to support more database type. look like this:

```java
dBScriptRunner.setTypeHandlerFactory(new MyTypeHandlerFactory());
dBScriptRunner.excute("select * from pub_param", "org.h2.Driver");
```

## LICENSE

[Apache License](LICENSE)