Browse Source

Code formatting.

Revert the change in hibernate.cfg.xml to use data source
Martin Tzvetanov Grigorov 11 years ago
parent
commit
7ee8ab3c13

+ 41 - 42
wicket/src/main/java/hellowicket/fortune/FortunePage.java

@@ -15,49 +15,48 @@ import org.hibernate.Session;
 import hellowicket.HibernateUtil;
 
 /**
- *
+ * A page that loads all fortune cookies
  */
 public class FortunePage extends WebPage
 {
-	public FortunePage()
-	{
-		final Session session = HibernateUtil.getSessionFactory().openSession();
-
-		Query query = session.createQuery("from Fortune");
-		query.setReadOnly(true);
-		List list = query.list();
-		List<Fortune> fortunes = new ArrayList<Fortune>(list);
-
-		session.close();
-
-		Fortune newFortune = new Fortune();
-		newFortune.message = "Additional fortune added at request time.";
-		fortunes.add(newFortune);
-
-		sort(fortunes);
-
-		ListView<Fortune> listView = new ListView<Fortune>("fortunes", fortunes)
-		{
-			@Override
-			protected void populateItem(ListItem<Fortune> item)
-			{
-				Fortune fortune = item.getModelObject();
-				item.add(new Label("id", fortune.id));
-				item.add(new Label("message", fortune.message));
-			}
-		};
-		add(listView);
-	}
-
-	private void sort(List<Fortune> fortunes)
-	{
-		Collections.sort(fortunes, new Comparator<Fortune>()
-		{
-			@Override
-			public int compare(Fortune f1, Fortune f2)
-			{
-				return f1.message.compareTo(f2.message);
-			}
-		});
-	}
+  public FortunePage()
+  {
+    Session session = HibernateUtil.getSessionFactory().openSession();
+
+    Query query = session.createQuery("from Fortune");
+    query.setReadOnly(true);
+    List list = query.list();
+    List<Fortune> fortunes = new ArrayList<Fortune>(list);
+    session.close();
+
+    Fortune newFortune = new Fortune();
+    newFortune.message = "Additional fortune added at request time.";
+    fortunes.add(newFortune);
+
+    sort(fortunes);
+
+    ListView<Fortune> listView = new ListView<Fortune>("fortunes", fortunes)
+    {
+      @Override
+      protected void populateItem(ListItem<Fortune> item)
+      {
+        Fortune fortune = item.getModelObject();
+        item.add(new Label("id", fortune.id));
+        item.add(new Label("message", fortune.message));
+      }
+    };
+    add(listView);
+  }
+
+  private void sort(List<Fortune> fortunes)
+  {
+    Collections.sort(fortunes, new Comparator<Fortune>()
+    {
+      @Override
+      public int compare(Fortune f1, Fortune f2)
+      {
+        return f1.message.compareTo(f2.message);
+      }
+    });
+  }
 }

+ 7 - 5
wicket/src/main/resources/hibernate.cfg.xml

@@ -3,11 +3,13 @@
         "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
 <hibernate-configuration>
     <session-factory>
-        <!--<property name="hibernate.connection.datasource">java:comp/env/jdbc/hello_world</property>-->
-        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
-        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hello_world?jdbcCompliantTruncation=false&amp;elideSetAutoCommits=true&amp;useLocalSessionState=true&amp;cachePrepStmts=true&amp;cacheCallableStmts=true&amp;alwaysSendSetIsolation=false&amp;prepStmtCacheSize=4096&amp;cacheServerConfiguration=true&amp;prepStmtCacheSqlLimit=2048&amp;zeroDateTimeBehavior=convertToNull&amp;traceProtocol=false&amp;useUnbufferedInput=false&amp;useReadAheadInput=false&amp;maintainTimeStats=false&amp;useServerPrepStmts&amp;cacheRSMetadata=true</property>
-        <property name="hibernate.connection.username">benchmarkdbuser</property>
-        <property name="hibernate.connection.password">benchmarkdbpass</property>
+        <property name="hibernate.connection.datasource">java:comp/env/jdbc/hello_world</property>
+
+        <!-- FOR LOCAL RUNS -->
+        <!--<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>-->
+        <!--<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hello_world?jdbcCompliantTruncation=false&amp;elideSetAutoCommits=true&amp;useLocalSessionState=true&amp;cachePrepStmts=true&amp;cacheCallableStmts=true&amp;alwaysSendSetIsolation=false&amp;prepStmtCacheSize=4096&amp;cacheServerConfiguration=true&amp;prepStmtCacheSqlLimit=2048&amp;zeroDateTimeBehavior=convertToNull&amp;traceProtocol=false&amp;useUnbufferedInput=false&amp;useReadAheadInput=false&amp;maintainTimeStats=false&amp;useServerPrepStmts&amp;cacheRSMetadata=true</property>-->
+        <!--<property name="hibernate.connection.username">benchmarkdbuser</property>-->
+        <!--<property name="hibernate.connection.password">benchmarkdbpass</property>-->
  
         <!-- SQL dialect -->
         <property name="dialect">org.hibernate.dialect.MySQLDialect</property>