X Tutup
Skip to content

Commit 0d2df99

Browse files
committed
iluwatar#216 Improve naming in Repository example
1 parent adbb4ac commit 0d2df99

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

repository/etc/repository.png

856 Bytes
Loading

repository/etc/repository.ucls

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
realizations="true" associations="true" dependencies="false" nesting-relationships="true">
44
<class id="1" language="java" name="com.iluwatar.repository.Person" project="repository"
55
file="/repository/src/main/java/com/iluwatar/repository/Person.java" binary="false" corner="BOTTOM_RIGHT">
6-
<position height="-1" width="-1" x="109" y="166"/>
6+
<position height="-1" width="-1" x="109" y="67"/>
77
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
88
sort-features="false" accessors="true" visibility="true">
99
<attributes public="true" package="true" protected="true" private="true" static="true"/>
1010
<operations public="true" package="true" protected="true" private="true" static="true"/>
1111
</display>
1212
</class>
13-
<interface id="2" language="java" name="com.iluwatar.repository.PersonDao" project="repository"
14-
file="/repository/src/main/java/com/iluwatar/repository/PersonDao.java" binary="false" corner="BOTTOM_RIGHT">
13+
<interface id="2" language="java" name="com.iluwatar.repository.PersonRepository" project="repository"
14+
file="/repository/src/main/java/com/iluwatar/repository/PersonRepository.java" binary="false" corner="BOTTOM_RIGHT">
1515
<position height="-1" width="-1" x="350" y="67"/>
1616
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
1717
sort-features="false" accessors="true" visibility="true">

repository/src/main/java/com/iluwatar/repository/App.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,39 +24,39 @@ public class App {
2424
public static void main(String[] args) {
2525
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
2626
"applicationContext.xml");
27-
PersonDao dao = context.getBean(PersonDao.class);
27+
PersonRepository repository = context.getBean(PersonRepository.class);
2828

2929
Person peter = new Person("Peter", "Sagan");
3030
Person nasta = new Person("Nasta", "Kuzminova");
3131

3232
// Add new Person records
33-
dao.save(peter);
34-
dao.save(nasta);
33+
repository.save(peter);
34+
repository.save(nasta);
3535

3636
// Count Person records
37-
System.out.println("Count Person records: " + dao.count());
37+
System.out.println("Count Person records: " + repository.count());
3838

3939
// Print all records
40-
List<Person> persons = (List<Person>) dao.findAll();
40+
List<Person> persons = (List<Person>) repository.findAll();
4141
for (Person person : persons) {
4242
System.out.println(person);
4343
}
4444

4545
// Find Person by surname
46-
System.out.println("Find by surname 'Sagan': " + dao.findBySurname("Sagan"));
46+
System.out.println("Find by surname 'Sagan': " + repository.findBySurname("Sagan"));
4747

4848
// Update Person
4949
nasta.setName("Barbora");
5050
nasta.setSurname("Spotakova");
51-
dao.save(nasta);
51+
repository.save(nasta);
5252

53-
System.out.println("Find by id 2: " + dao.findOne(2L));
53+
System.out.println("Find by id 2: " + repository.findOne(2L));
5454

5555
// Remove record from Person
56-
dao.delete(2L);
56+
repository.delete(2L);
5757

5858
// And finally count records
59-
System.out.println("Count Person records: " + dao.count());
59+
System.out.println("Count Person records: " + repository.count());
6060

6161
context.close();
6262
}

repository/src/main/java/com/iluwatar/repository/PersonDao.java renamed to repository/src/main/java/com/iluwatar/repository/PersonRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*/
1313
@Repository
14-
public interface PersonDao extends CrudRepository<Person, Long> {
14+
public interface PersonRepository extends CrudRepository<Person, Long> {
1515

1616
public List<Person> findBySurname(String surname);
1717
}

0 commit comments

Comments
 (0)
X Tutup