summaryrefslogtreecommitdiff
path: root/myapp/src/main/java/io
diff options
context:
space:
mode:
Diffstat (limited to 'myapp/src/main/java/io')
-rw-r--r--myapp/src/main/java/io/trygvis/container/myapp/AddressBook.java11
-rw-r--r--myapp/src/main/java/io/trygvis/container/myapp/Person.java5
2 files changed, 15 insertions, 1 deletions
diff --git a/myapp/src/main/java/io/trygvis/container/myapp/AddressBook.java b/myapp/src/main/java/io/trygvis/container/myapp/AddressBook.java
index c8440ff..ec0bffa 100644
--- a/myapp/src/main/java/io/trygvis/container/myapp/AddressBook.java
+++ b/myapp/src/main/java/io/trygvis/container/myapp/AddressBook.java
@@ -1,11 +1,13 @@
package io.trygvis.container.myapp;
+import javax.persistence.TypedQuery;
import java.io.BufferedReader;
import java.io.EOFException;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
+import java.util.List;
public class AddressBook {
@@ -109,7 +111,14 @@ public class AddressBook {
public static class ListCommand implements Command {
@Override
public void run(Connection c) throws Exception {
-// PersonDao.insertInto(c, new Person());
+ TypedQuery<Person> p = PersonDao.query(c);
+
+ List<Person> resultList = p.getResultList();
+ for (int i = 0; i < resultList.size(); i++) {
+ Person person = resultList.get(i);
+ System.out.println("#" + i);
+ System.out.println("Name: " + person.name);
+ }
}
}
}
diff --git a/myapp/src/main/java/io/trygvis/container/myapp/Person.java b/myapp/src/main/java/io/trygvis/container/myapp/Person.java
index ab883b2..6a7a694 100644
--- a/myapp/src/main/java/io/trygvis/container/myapp/Person.java
+++ b/myapp/src/main/java/io/trygvis/container/myapp/Person.java
@@ -13,4 +13,9 @@ public class Person {
public Person(String name) {
this.name = name;
}
+
+ public Person(Long id, String name) {
+ this.id = id;
+ this.name = name;
+ }
}