Last active
April 24, 2017 23:11
-
-
Save bisignam/2410649e688bb683102b6a95f59d6105 to your computer and use it in GitHub Desktop.
This file contains 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 final static Constants { | |
public final static String COMPLEX_QUERY = "SELECT * FROM A_VERY_COMPLEX_QUERY"; | |
} |
This file contains 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
@Repository | |
public class Repository1 { | |
public List<Item1> getItems() { | |
List<Item1> items = new ArrayList<>(); | |
List<Map> rows = getJdbcTemplate().queryForList(Constants.COMPLEX_QUERY); | |
for (Map row : rows) { | |
Item1 item = new Item(); | |
item.setX((String)(row.get("X"))); | |
item.setY((String)row.get("Y")); | |
item.setZ((String)row.get("Z")); | |
items.add(item); | |
} | |
return items; | |
} | |
} |
This file contains 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
@Repository | |
public class Repository2 { | |
public List<Item2> getItems(final Integer param){ | |
List<Item2> items = new ArrayList<>(); | |
List<Map> rows = getJdbcTemplate().queryForList(Constants.COMPLEX_QUERY + " and param="+param); | |
for (Map row : rows) { | |
Item2 item = new Item2(); | |
item.setA((String)(row.get("A"))); | |
item.setB((String)row.get("B")); | |
item.setC((String)row.get("C")); | |
items.add(item); | |
} | |
return items; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment