使用JdbcTemplate查询到neo4j的JSON字符串?

时间:2015-06-28 23:55:52

标签: json jdbc neo4j jdbctemplate

我想使用JdbcTemplate和Neo4j JDBC驱动程序来查询我的neo4j数据库并返回一个JSON字符串。

是否有现成的方法来执行此操作?

我用谷歌搜索,我找不到一个。

它看起来像creating a home cooked RowMapper as per here.

1 个答案:

答案 0 :(得分:0)

The query :
MATCH (s:Site) - [r] - (ss:SiteState) return s,ss;

it return a json but for my use i use an object 

public class SiteRowMapper implements RowMapper<Site> {

    @Override
    public Site mapRow(ResultSet rs, int rowNum) throws SQLException {
        Site site = new Site();
        SiteState siteState = new SiteState();
        Gson json = new Gson();
        site = json.fromJson(rs.getString("s"), Site.class);
        siteState = json.fromJson(rs.getString("ss"), SiteState.class);
        site.setName(siteState.getName());
        return site;
    }

}