Created
November 6, 2015 13:15
-
-
Save rsds143/52e202347312367ece0b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Record{ | |
| private String value; | |
| private Integer id; | |
| //setters and getters follow | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class UsingMapper{ | |
| @Autowired | |
| private DumbMapper mapper; | |
| @Autowired | |
| private Session session; | |
| public List<Record> queryRecords(){ | |
| ResultSet resultSet = session.execute("SELECT * FROM records"); | |
| List<Record> records = mapper.mapList(Record.class, resultSet); | |
| return records; | |
| } | |
| public Record queryRecord(Integer id){ | |
| ResultSet resultSet = session.execute ("SELECT * FROM records WHERE id = " + id); | |
| Record record = mapper.map(Record.class, resultSet); | |
| return record; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment