summaryrefslogtreecommitdiff
path: root/myapp
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-08-03 23:13:32 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2013-08-03 23:13:32 +0200
commit2b1c32590db960be2b5f62897e65bb10d434cae0 (patch)
tree84623e4293f59f67331a7760a700121737313c48 /myapp
parentdf92538ab3d83da9839f08b28fc8a67317565463 (diff)
downloadcontainer-playground-2b1c32590db960be2b5f62897e65bb10d434cae0.tar.gz
container-playground-2b1c32590db960be2b5f62897e65bb10d434cae0.tar.bz2
container-playground-2b1c32590db960be2b5f62897e65bb10d434cae0.tar.xz
container-playground-2b1c32590db960be2b5f62897e65bb10d434cae0.zip
wip
Diffstat (limited to 'myapp')
-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;
+ }
}