Skip to content

Commit

Permalink
better documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmcclean committed Aug 5, 2015
1 parent ee32fa4 commit f594170
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
38 changes: 37 additions & 1 deletion micro-data/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,40 @@ Simply inject the Repository into your Rest Resource
}



# Plain ol' JDBC

[JDBC Template Exmaple App](https://github.com/aol/micro-server/tree/master/micro-data/src/test/java/app/jdbc/com/aol/micro/server)

The micro-data plugin also facilitate JDBC use via the Spring JDBCTemplate. A Spring called SQL will be created that contains a JDBCTemplate, simply inject SQL into your classes.

e.g.

@Rest
@Path("/persistence")
public class PersistentResource {

private final SQL dao;

@Autowired
public PersistentResource(SQL dao) {

this.dao = dao;
}

@GET
@Produces("text/plain")
@Path("/create")
public String createEntity() {
dao.getJdbc().update("insert into t_jdbc VALUES (1,'hello','world',1)");

return "ok";
}

@GET
@Produces("application/json")
@Path("/get")
public JdbcEntity get() {
return dao.getJdbc().<JdbcEntity> queryForObject("select * from t_jdbc", new BeanPropertyRowMapper(JdbcEntity.class));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Component;

import com.aol.micro.server.auto.discovery.RestResource;
import com.aol.micro.server.auto.discovery.Rest;
import com.aol.micro.server.spring.datasource.jdbc.SQL;

@Component
@Rest
@Path("/persistence")
public class PersistentResource implements RestResource {
public class PersistentResource {

private final SQL dao;

Expand Down

0 comments on commit f594170

Please sign in to comment.