+ default query
authorAlexandre Bertails <bertails@gmail.com>
Sun, 13 Mar 2011 18:13:21 -0400
changeset 361 277fe8b0313d
parent 360 1420a9d575b8
child 362 6aa359632373
+ default query
directmapping-webapp/src/main/resources/queries/default
directmapping-webapp/src/main/scala/Servlet.scala
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/default	Sun Mar 13 18:13:21 2011 -0400
@@ -0,0 +1,5 @@
+CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
+INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
+CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT, FOREIGN KEY (addr) REFERENCES Addresses(ID));
+INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
+INSERT INTO People (ID, fname, addr) VALUES (8, "Sue", NULL);
\ No newline at end of file
--- a/directmapping-webapp/src/main/scala/Servlet.scala	Sun Mar 13 18:06:23 2011 -0400
+++ b/directmapping-webapp/src/main/scala/Servlet.scala	Sun Mar 13 18:13:21 2011 -0400
@@ -17,13 +17,7 @@
 
 object DirectMappingWebapp {
 
-  val defaultSQL = 
-"""CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
-INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
-CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT, FOREIGN KEY (addr) REFERENCES Addresses(ID));
-INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
-INSERT INTO People (ID, fname, addr) VALUES (8, "Sue", NULL);
-"""
+  val defaultSQL = QueryManager.getQueries("default")
 
   val encoding = "utf-8"
 
@@ -203,7 +197,7 @@
     }
   }
 
-  def getQueries:Map[String, String] = {
+  lazy val getQueries:Map[String, String] = {
     val classloader = this.getClass.getClassLoader
     val entries = getResourceListing("queries/")
     val queries = entries map { entry => {