Browse Source

Update grizzly-jersey and undertow-jersey (#4778)

* Update to EntityManager in grizzly-jersey

* Update grizzly-jersey to use JPA. Add sorting to prevent DB transaction deadlock in the update test

* Fix connection string to use tfb-database

* Update undertow-jersey also

* Fix mustashe template

* Fix Java 11 compilation
Radoslav Petrov 6 years ago
parent
commit
f3ab166757
28 changed files with 482 additions and 366 deletions
  1. 28 0
      frameworks/Java/grizzly/src-jersey/main/java/hello/EMFactory.java
  2. 4 10
      frameworks/Java/grizzly/src-jersey/main/java/hello/FortunesResource.java
  3. 2 1
      frameworks/Java/grizzly/src-jersey/main/java/hello/JsonResource.java
  4. 0 39
      frameworks/Java/grizzly/src-jersey/main/java/hello/SessionFactoryFactory.java
  5. 2 3
      frameworks/Java/grizzly/src-jersey/main/java/hello/TFBApplication.java
  6. 21 8
      frameworks/Java/grizzly/src-jersey/main/java/hello/WorldResource.java
  7. 25 16
      frameworks/Java/grizzly/src-jersey/main/java/hello/domain/Fortune.java
  8. 16 4
      frameworks/Java/grizzly/src-jersey/main/java/hello/domain/World.java
  9. 30 0
      frameworks/Java/grizzly/src-jersey/main/resources/META-INF/persistence.xml
  10. 0 18
      frameworks/Java/grizzly/src-jersey/main/resources/hibernate.cfg.xml
  11. 6 4
      frameworks/Java/undertow-jersey/benchmark_config.json
  12. 4 4
      frameworks/Java/undertow-jersey/pom.xml
  13. 11 9
      frameworks/Java/undertow-jersey/src/main/java/hello/Common.java
  14. 0 80
      frameworks/Java/undertow-jersey/src/main/java/hello/DbResource.java
  15. 28 0
      frameworks/Java/undertow-jersey/src/main/java/hello/EMFactory.java
  16. 27 37
      frameworks/Java/undertow-jersey/src/main/java/hello/FortunesResource.java
  17. 5 2
      frameworks/Java/undertow-jersey/src/main/java/hello/JerseyWebServer.java
  18. 13 14
      frameworks/Java/undertow-jersey/src/main/java/hello/JsonResource.java
  19. 12 11
      frameworks/Java/undertow-jersey/src/main/java/hello/PlaintextResource.java
  20. 0 39
      frameworks/Java/undertow-jersey/src/main/java/hello/SessionFactoryFactory.java
  21. 134 0
      frameworks/Java/undertow-jersey/src/main/java/hello/WorldResource.java
  22. 31 25
      frameworks/Java/undertow-jersey/src/main/java/hello/domain/Fortune.java
  23. 21 7
      frameworks/Java/undertow-jersey/src/main/java/hello/domain/World.java
  24. 30 0
      frameworks/Java/undertow-jersey/src/main/resources/META-INF/persistence.xml
  25. 2 2
      frameworks/Java/undertow-jersey/src/main/resources/fortunes.mustache
  26. 0 17
      frameworks/Java/undertow-jersey/src/main/resources/hibernate.cfg.xml
  27. 30 0
      frameworks/Java/undertow-jersey/src/main/resources/hikarycp/META-INF/persistence.xml
  28. 0 16
      frameworks/Java/undertow-jersey/src/main/resources/hikarycp/hibernate.cfg.xml

+ 28 - 0
frameworks/Java/grizzly/src-jersey/main/java/hello/EMFactory.java

@@ -0,0 +1,28 @@
+package hello;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.ws.rs.ext.Provider;
+
+import org.glassfish.hk2.api.Factory;
+
+@Provider
+public class EMFactory implements Factory<EntityManagerFactory> {
+	private EntityManagerFactory emf;
+
+	@Inject
+	public EMFactory() {
+		emf = Persistence.createEntityManagerFactory("0-TFB");
+	}
+
+	@Override
+	public void dispose(EntityManagerFactory emf) {
+		emf.close();
+	}
+
+	@Override
+	public EntityManagerFactory provide() {
+		return emf;
+	}
+}

+ 4 - 10
frameworks/Java/grizzly/src-jersey/main/java/hello/FortunesResource.java

@@ -8,31 +8,25 @@ import java.util.List;
 
 
 import javax.inject.Inject;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import javax.inject.Singleton;
+import javax.persistence.EntityManagerFactory;
 import javax.ws.rs.GET;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.Produces;
 
 
 import org.glassfish.jersey.server.mvc.Template;
 import org.glassfish.jersey.server.mvc.Template;
-import org.hibernate.Criteria;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
 
 
 @Singleton
 @Singleton
 @Path("/fortunes")
 @Path("/fortunes")
 public class FortunesResource {
 public class FortunesResource {
 	@Inject
 	@Inject
-	private SessionFactory sessionFactory;
+	private EntityManagerFactory emf;
 
 
-	@SuppressWarnings("unchecked")
 	@GET
 	@GET
 	@Produces(TEXT_HTML + "; charset=utf-8")
 	@Produces(TEXT_HTML + "; charset=utf-8")
 	@Template(name = "/fortunes.mustache")
 	@Template(name = "/fortunes.mustache")
 	public List<Fortune> fortunes() {
 	public List<Fortune> fortunes() {
-		List<Fortune> fortunes = null;
-		Session session = sessionFactory.openSession();
-		Criteria criteria = session.createCriteria(Fortune.class);
-		fortunes = new ArrayList<>(criteria.list());
-		session.close();
+		List<Fortune> fortunes = new ArrayList<>(emf.createEntityManager()
+				.createQuery("SELECT f FROM Fortune f", Fortune.class).getResultList());
 		fortunes.add(new Fortune(0, "Additional fortune added at request time."));
 		fortunes.add(new Fortune(0, "Additional fortune added at request time."));
 		fortunes.sort(null);
 		fortunes.sort(null);
 		return fortunes;
 		return fortunes;

+ 2 - 1
frameworks/Java/grizzly/src-jersey/main/java/hello/JsonResource.java

@@ -2,8 +2,9 @@ package hello;
 
 
 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
 
 
-import javax.inject.Singleton;
 import java.util.Collections;
 import java.util.Collections;
+
+import javax.inject.Singleton;
 import javax.ws.rs.GET;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.Produces;

+ 0 - 39
frameworks/Java/grizzly/src-jersey/main/java/hello/SessionFactoryFactory.java

@@ -1,39 +0,0 @@
-package hello;
-
-import hello.domain.Fortune;
-import hello.domain.World;
-
-import javax.ws.rs.ext.Provider;
-
-import org.glassfish.hk2.api.Factory;
-import org.hibernate.SessionFactory;
-import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
-import org.hibernate.cfg.Configuration;
-
-@Provider
-public class SessionFactoryFactory implements Factory<SessionFactory> {
-	private final SessionFactory factory;
-
-	public SessionFactoryFactory() {
-		factory = createSessionFactory();
-	}
-
-	@Override
-	public SessionFactory provide() {
-		return factory;
-	}
-
-	@Override
-	public void dispose(SessionFactory factory) {
-		factory.close();
-	}
-
-	private static SessionFactory createSessionFactory() {
-		Configuration configuration = new Configuration().configure();
-		configuration.addAnnotatedClass(World.class);
-		configuration.addAnnotatedClass(Fortune.class);
-		StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
-		builder.applySettings(configuration.getProperties());
-		return configuration.buildSessionFactory(builder.build());
-	}
-}

+ 2 - 3
frameworks/Java/grizzly/src-jersey/main/java/hello/TFBApplication.java

@@ -1,12 +1,12 @@
 package hello;
 package hello;
 
 
 import javax.inject.Singleton;
 import javax.inject.Singleton;
+import javax.persistence.EntityManagerFactory;
 
 
 import org.glassfish.hk2.utilities.binding.AbstractBinder;
 import org.glassfish.hk2.utilities.binding.AbstractBinder;
 import org.glassfish.jersey.jackson.JacksonFeature;
 import org.glassfish.jersey.jackson.JacksonFeature;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.server.mvc.mustache.MustacheMvcFeature;
 import org.glassfish.jersey.server.mvc.mustache.MustacheMvcFeature;
-import org.hibernate.SessionFactory;
 
 
 public class TFBApplication extends ResourceConfig {
 public class TFBApplication extends ResourceConfig {
 	public TFBApplication() {
 	public TFBApplication() {
@@ -17,8 +17,7 @@ public class TFBApplication extends ResourceConfig {
 		register(new AbstractBinder() {
 		register(new AbstractBinder() {
 			@Override
 			@Override
 			protected void configure() {
 			protected void configure() {
-				bindFactory(SessionFactoryFactory.class).to(SessionFactory.class).in(
-						Singleton.class);
+				bindFactory(EMFactory.class).to(EntityManagerFactory.class).in(Singleton.class);
 			}
 			}
 		});
 		});
 	}
 	}

+ 21 - 8
frameworks/Java/grizzly/src-jersey/main/java/hello/WorldResource.java

@@ -2,7 +2,8 @@ package hello;
 
 
 import hello.domain.World;
 import hello.domain.World;
 
 
-import java.util.Optional;
+import java.util.Arrays;
+import java.util.Comparator;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.Future;
@@ -10,6 +11,8 @@ import java.util.concurrent.ThreadLocalRandom;
 
 
 import javax.inject.Inject;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import javax.inject.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
 import javax.ws.rs.GET;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.Produces;
@@ -17,7 +20,6 @@ import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MediaType;
 
 
 import org.hibernate.Session;
 import org.hibernate.Session;
-import org.hibernate.SessionFactory;
 import org.hibernate.Transaction;
 import org.hibernate.Transaction;
 
 
 @Singleton
 @Singleton
@@ -25,12 +27,13 @@ import org.hibernate.Transaction;
 @Path("/db")
 @Path("/db")
 public class WorldResource {
 public class WorldResource {
 	@Inject
 	@Inject
-	private SessionFactory sessionFactory;
+	private EntityManagerFactory emf;
 
 
 	@GET
 	@GET
 	public Object db() throws InterruptedException, ExecutionException {
 	public Object db() throws InterruptedException, ExecutionException {
 		Callable<World> callable = () -> {
 		Callable<World> callable = () -> {
-			Session session = sessionFactory.openSession();
+			EntityManager em = emf.createEntityManager();
+			Session session = em.unwrap(Session.class);
 			session.setDefaultReadOnly(true);
 			session.setDefaultReadOnly(true);
 			try {
 			try {
 				return (World) session.byId(World.class).load(randomWorld());
 				return (World) session.byId(World.class).load(randomWorld());
@@ -50,7 +53,7 @@ public class WorldResource {
 		final World[] worlds = new World[queries];
 		final World[] worlds = new World[queries];
 
 
 		Callable<World[]> callable = () -> {
 		Callable<World[]> callable = () -> {
-			Session session = sessionFactory.openSession();
+			Session session = emf.createEntityManager().unwrap(Session.class);
 			session.setDefaultReadOnly(true);
 			session.setDefaultReadOnly(true);
 			try {
 			try {
 				for (int i = 0; i < queries; i++) {
 				for (int i = 0; i < queries; i++) {
@@ -73,19 +76,29 @@ public class WorldResource {
 		final World[] worlds = new World[queries];
 		final World[] worlds = new World[queries];
 
 
 		Callable<World[]> callable = () -> {
 		Callable<World[]> callable = () -> {
-			Session session = sessionFactory.openSession();
+			Session session = emf.createEntityManager().unwrap(Session.class);
 			session.setDefaultReadOnly(false);
 			session.setDefaultReadOnly(false);
 			Transaction txn = session.beginTransaction();
 			Transaction txn = session.beginTransaction();
 
 
 			try {
 			try {
 				// using write batching. See the data source properties provided
 				// using write batching. See the data source properties provided
 				// in the configuration file
 				// in the configuration file
+
+				// 1. Read and update the entities from the DB
 				for (int i = 0; i < queries; i++) {
 				for (int i = 0; i < queries; i++) {
 					final World world = (World) session.byId(World.class).load(randomWorld());
 					final World world = (World) session.byId(World.class).load(randomWorld());
-					world.randomNumber = randomWorld();
-					session.persist(world);
+					world.setRandomNumber(randomWorld());
 					worlds[i] = world;
 					worlds[i] = world;
 				}
 				}
+
+				// 2. Sort the array to prevent transaction deadlock in the DB
+				Arrays.sort(worlds, Comparator.comparingInt(World::getId));
+
+				// 3. Actually save the entities
+				for (int i = 0; i < worlds.length; i++) {
+					session.persist(worlds[i]);
+				}
+
 				session.flush();
 				session.flush();
 				session.clear();
 				session.clear();
 				txn.commit();
 				txn.commit();

+ 25 - 16
frameworks/Java/grizzly/src-jersey/main/java/hello/domain/Fortune.java

@@ -8,20 +8,29 @@ import javax.persistence.Id;
 @Entity
 @Entity
 public class Fortune implements Comparable<Fortune> {
 public class Fortune implements Comparable<Fortune> {
 
 
-  @Id
-  @GeneratedValue(strategy = GenerationType.IDENTITY)
-  public int id;
-  public String message;
-
-  public Fortune() { }
-
-  public Fortune(int id, String message) {
-    this.id = id;
-    this.message = message;
-  }
-
-  @Override
-  public int compareTo(Fortune other) {
-    return message.compareTo(other.message);
-  }
+	@Id
+	@GeneratedValue(strategy = GenerationType.IDENTITY)
+	private int id;
+	private String message;
+
+	public Fortune() {
+	}
+
+	public Fortune(int id, String message) {
+		this.id = id;
+		this.message = message;
+	}
+
+	public int getId() {
+		return id;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	@Override
+	public int compareTo(Fortune other) {
+		return message.compareTo(other.message);
+	}
 }
 }

+ 16 - 4
frameworks/Java/grizzly/src-jersey/main/java/hello/domain/World.java

@@ -8,9 +8,21 @@ import javax.persistence.Id;
 @Entity
 @Entity
 public class World {
 public class World {
 
 
-  @Id
-  @GeneratedValue(strategy = GenerationType.IDENTITY)
-  public int id;
-  public int randomNumber;
+	@Id
+	@GeneratedValue(strategy = GenerationType.IDENTITY)
+	private int id;
+	private int randomNumber;
+
+	public int getId() {
+		return id;
+	}
+
+	public int getRandomNumber() {
+		return randomNumber;
+	}
+
+	public void setRandomNumber(int randomNumber) {
+		this.randomNumber = randomNumber;
+	}
 
 
 }
 }

+ 30 - 0
frameworks/Java/grizzly/src-jersey/main/resources/META-INF/persistence.xml

@@ -0,0 +1,30 @@
+<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
+             http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
+	version="2.1">
+
+	<persistence-unit name="0-TFB">
+		<description>
+			The Techempower Framework Benchmarks persistence unit
+		</description>
+		<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+		<properties>
+			<property name="hibernate.connection.provider_class" value="org.hibernate.hikaricp.internal.HikariCPConnectionProvider" />
+			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
+			<property name="hibernate.cache.use_query_cache" value="false" />
+			<property name="hibernate.show_sql" value="false" />
+			<property name="hibernate.jdbc.batch_size" value="30" />
+			<property name="hibernate.jdbc.batch_versioned_data" value="true" />
+			<property name="hibernate.hikari.minimumIdle" value="256" />
+			<property name="hibernate.hikari.maximumPoolSize" value="256" />
+			<property name="hibernate.hikari.idleTimeout" value="30000" />
+			<property name="hibernate.hikari.dataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" />
+			<property name="hibernate.hikari.dataSource.url" value="jdbc:mysql://tfb-database: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&amp;useSSL=false" />
+			<property name="hibernate.hikari.dataSource.user" value="benchmarkdbuser" />
+			<property name="hibernate.hikari.dataSource.password" value="benchmarkdbpass" />
+			<property name="hibernate.show_sql" value="false" />
+			<property name="hibernate.hbm2ddl.auto" value="none" />
+		</properties>
+	</persistence-unit>
+</persistence>

+ 0 - 18
frameworks/Java/grizzly/src-jersey/main/resources/hibernate.cfg.xml

@@ -1,18 +0,0 @@
-<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
-<hibernate-configuration>
-  <session-factory>
-    <property name="hibernate.connection.provider_class">org.hibernate.hikaricp.internal.HikariCPConnectionProvider</property>
-    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
-    <property name="hibernate.cache.use_query_cache">false</property>
-    <property name="hibernate.show_sql">false</property>
-    <property name="hibernate.jdbc.batch_size">30</property>
-    <property name="hibernate.jdbc.batch_versioned_data">true</property>
-    <property name="hibernate.hikari.minimumIdle">256</property>
-    <property name="hibernate.hikari.maximumPoolSize">256</property>
-    <property name="hibernate.hikari.idleTimeout">30000</property>
-    <property name="hibernate.hikari.dataSourceClassName">com.mysql.jdbc.jdbc2.optional.MysqlDataSource</property>
-    <property name="hibernate.hikari.dataSource.url">jdbc:mysql://tfb-database: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&amp;useSSL=false</property>
-    <property name="hibernate.hikari.dataSource.user">benchmarkdbuser</property>
-    <property name="hibernate.hikari.dataSource.password">benchmarkdbpass</property>
-  </session-factory>
-</hibernate-configuration>

+ 6 - 4
frameworks/Java/undertow-jersey/benchmark_config.json

@@ -3,8 +3,9 @@
   "tests": [{
   "tests": [{
     "default": {
     "default": {
       "json_url": "/json",
       "json_url": "/json",
-      "db_url": "/db?single=true",
-      "query_url": "/db?queries=",
+      "db_url": "/db",
+      "query_url": "/db/queries?queries=",
+      "update_url": "/db/updates?queries=",
       "fortune_url": "/fortunes",
       "fortune_url": "/fortunes",
       "plaintext_url": "/plaintext",
       "plaintext_url": "/plaintext",
       "port": 8080,
       "port": 8080,
@@ -24,8 +25,9 @@
       "versus": "servlet-raw"
       "versus": "servlet-raw"
     },
     },
     "hikaricp": {
     "hikaricp": {
-      "db_url": "/db?single=true",
-      "query_url": "/db?queries=",
+      "db_url": "/db",
+      "query_url": "/db/queries?queries=",
+      "update_url": "/db/updates?queries=",
       "fortune_url": "/fortunes",
       "fortune_url": "/fortunes",
       "port": 8080,
       "port": 8080,
       "approach": "Realistic",
       "approach": "Realistic",

+ 4 - 4
frameworks/Java/undertow-jersey/pom.xml

@@ -42,10 +42,10 @@
             <directory>src/main/resources/</directory>
             <directory>src/main/resources/</directory>
             <includes>
             <includes>
               <include>fortunes.mustache</include>
               <include>fortunes.mustache</include>
-              <include>hibernate.cfg.xml</include>
+              <include>META-INF/persistence.xml</include>
             </includes>
             </includes>
             <excludes>
             <excludes>
-              <exclude>hikarycp/hibernate.cfg.xml</exclude>
+              <exclude>hikarycp/META-INF/persistence.xml</exclude>
             </excludes>
             </excludes>
           </resource>
           </resource>
         </resources>
         </resources>
@@ -68,13 +68,13 @@
               <include>fortunes.mustache</include>
               <include>fortunes.mustache</include>
             </includes>
             </includes>
             <excludes>
             <excludes>
-              <exclude>hibernate.cfg.xml</exclude>
+              <exclude>META-INF/persistence.xml</exclude>
             </excludes>
             </excludes>
           </resource>
           </resource>
           <resource>
           <resource>
             <directory>src/main/resources/hikarycp</directory>
             <directory>src/main/resources/hikarycp</directory>
             <includes>
             <includes>
-              <include>hibernate.cfg.xml</include>
+              <include>META-INF/persistence.xml</include>
             </includes>
             </includes>
           </resource>
           </resource>
         </resources>
         </resources>

+ 11 - 9
frameworks/Java/undertow-jersey/src/main/java/hello/Common.java

@@ -1,18 +1,20 @@
 package hello;
 package hello;
 
 
-import java.util.concurrent.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 
 
 /**
 /**
  * @author denkab
  * @author denkab
  */
  */
-public class Common
-{
+final class Common {
+	private Common() {
+	}
 
 
-  private static final int cpuCount = Runtime.getRuntime().availableProcessors();
-
-  public static ExecutorService EXECUTOR = new ThreadPoolExecutor(
-      cpuCount * 2, cpuCount * 25, 200, TimeUnit.MILLISECONDS,
-      new LinkedBlockingQueue<Runnable>(cpuCount * 100),
-      new ThreadPoolExecutor.CallerRunsPolicy());
+	private static final int cpuCount = Runtime.getRuntime().availableProcessors();
 
 
+	static ExecutorService EXECUTOR = new ThreadPoolExecutor(cpuCount * 2, cpuCount * 25, 200,
+			TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(cpuCount * 100),
+			new ThreadPoolExecutor.CallerRunsPolicy());
 }
 }

+ 0 - 80
frameworks/Java/undertow-jersey/src/main/java/hello/DbResource.java

@@ -1,80 +0,0 @@
-package hello;
-
-import hello.domain.*;
-import org.hibernate.*;
-
-import javax.inject.*;
-import javax.ws.rs.*;
-import java.util.*;
-import java.util.concurrent.*;
-
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
-
-@Singleton
-@Path("/db")
-public class DbResource
-{
-
-  private static final int DB_ROWS = 10000;
-
-  @Inject
-  private SessionFactory sessionFactory;
-
-  @GET
-  @Produces(APPLICATION_JSON)
-  public Object db(@QueryParam("queries") String queryParam,
-      @QueryParam("single") boolean isSingle)
-      throws ExecutionException, InterruptedException
-  {
-
-    final int queries = getQueries(queryParam);
-    final World[] worlds = new World[queries];
-    final Random random = ThreadLocalRandom.current();
-
-    Map<Integer, Future<World>> futureWorlds = new ConcurrentHashMap<>();
-    for (int i = 0; i < queries; i++)
-    {
-      futureWorlds.put(i, Common.EXECUTOR.submit(new Callable<World>()
-      {
-        @Override
-        public World call() throws Exception
-        {
-          Session session = sessionFactory.openSession();
-          session.setDefaultReadOnly(true);
-
-          try
-          {
-            return (World)session.byId(World.class).load(
-                random.nextInt(DB_ROWS) + 1);
-          }
-          finally
-          {
-            session.close();
-          }
-        }
-      }));
-    }
-
-    for (int i = 0; i < queries; i++)
-    {
-      worlds[i] = futureWorlds.get(i).get();
-    }
-    return isSingle ? worlds[0] : worlds;
-  }
-
-  private int getQueries(String proto)
-  {
-    int result = 1;
-    try
-    {
-      if (proto != null && !proto.trim().isEmpty())
-      {
-        result = Integer.parseInt(proto);
-      }
-    }
-    catch (NumberFormatException e)
-    {/* by test contract */}
-
-    return Math.min(500, Math.max(1, result));
-  }
-}

+ 28 - 0
frameworks/Java/undertow-jersey/src/main/java/hello/EMFactory.java

@@ -0,0 +1,28 @@
+package hello;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.ws.rs.ext.Provider;
+
+import org.glassfish.hk2.api.Factory;
+
+@Provider
+public class EMFactory implements Factory<EntityManagerFactory> {
+	private EntityManagerFactory emf;
+
+	@Inject
+	public EMFactory() {
+		emf = Persistence.createEntityManagerFactory("0-TFB");
+	}
+
+	@Override
+	public void dispose(EntityManagerFactory emf) {
+		emf.close();
+	}
+
+	@Override
+	public EntityManagerFactory provide() {
+		return emf;
+	}
+}

+ 27 - 37
frameworks/Java/undertow-jersey/src/main/java/hello/FortunesResource.java

@@ -1,44 +1,34 @@
 package hello;
 package hello;
 
 
-import hello.domain.*;
-import org.glassfish.jersey.server.mvc.*;
-import org.hibernate.*;
-
-import javax.inject.*;
-import javax.ws.rs.*;
-import java.util.*;
-
 import static javax.ws.rs.core.MediaType.TEXT_HTML;
 import static javax.ws.rs.core.MediaType.TEXT_HTML;
+import hello.domain.Fortune;
 
 
-@Singleton
-@Path("/fortunes")
-public class FortunesResource
-{
-
-  @Inject
-  private SessionFactory sessionFactory;
-
-  @GET
-  @Produces(TEXT_HTML + "; charset=utf-8")
-  public Viewable fortunes()
-  {
-    final Session session = sessionFactory.openSession();
-    final List<Fortune> fortunes = new ArrayList<>(
-        session.createCriteria(Fortune.class).list());
-    fortunes.add(new Fortune(0, "Additional fortune added at request time."));
-    Collections.sort(fortunes);
+import java.util.ArrayList;
+import java.util.List;
 
 
-    session.close();
-    return new Viewable("/fortunes.mustache", new Scope(fortunes));
-  }
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import javax.persistence.EntityManagerFactory;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
 
 
-  public static class Scope
-  {
-    public List fortunes;
+import org.glassfish.jersey.server.mvc.Template;
 
 
-    public Scope(final List fortunes)
-    {
-      this.fortunes = fortunes;
-    }
-  }
-}
+@Singleton
+@Path("/fortunes")
+public class FortunesResource {
+	@Inject
+	private EntityManagerFactory emf;
+
+	@GET
+	@Produces(TEXT_HTML + "; charset=utf-8")
+	@Template(name = "/fortunes.mustache")
+	public List<Fortune> fortunes() {
+		List<Fortune> fortunes = new ArrayList<>(emf.createEntityManager()
+				.createQuery("SELECT f FROM Fortune f", Fortune.class).getResultList());
+		fortunes.add(new Fortune(0, "Additional fortune added at request time."));
+		fortunes.sort(null);
+		return fortunes;
+	}
+}

+ 5 - 2
frameworks/Java/undertow-jersey/src/main/java/hello/JerseyWebServer.java

@@ -3,12 +3,15 @@ package hello;
 import hello.undertow.*;
 import hello.undertow.*;
 import io.undertow.*;
 import io.undertow.*;
 import io.undertow.server.handlers.*;
 import io.undertow.server.handlers.*;
+
 import org.apache.commons.cli.*;
 import org.apache.commons.cli.*;
 import org.glassfish.hk2.utilities.binding.AbstractBinder;
 import org.glassfish.hk2.utilities.binding.AbstractBinder;
 import org.glassfish.jersey.server.*;
 import org.glassfish.jersey.server.*;
 import org.hibernate.*;
 import org.hibernate.*;
 
 
 import javax.inject.*;
 import javax.inject.*;
+import javax.persistence.EntityManagerFactory;
+
 import java.util.*;
 import java.util.*;
 
 
 public class JerseyWebServer
 public class JerseyWebServer
@@ -34,7 +37,7 @@ public class JerseyWebServer
     final String dbHost = cmd.getOptionValue("dbhost", "tfb-database");
     final String dbHost = cmd.getOptionValue("dbhost", "tfb-database");
     final int dbPort = Integer.parseInt(cmd.getOptionValue("dbport", "3306"));
     final int dbPort = Integer.parseInt(cmd.getOptionValue("dbport", "3306"));
 
 
-    ResourceConfig config = new ResourceConfig(DbResource.class,
+    ResourceConfig config = new ResourceConfig(WorldResource.class,
         FortunesResource.class, JsonResource.class, PlaintextResource.class,
         FortunesResource.class, JsonResource.class, PlaintextResource.class,
         JsonMessageBodyWriter.class, ServerResponseFilter.class, RequestExceptionMapper.class);
         JsonMessageBodyWriter.class, ServerResponseFilter.class, RequestExceptionMapper.class);
 
 
@@ -52,7 +55,7 @@ public class JerseyWebServer
 	config.register(new AbstractBinder() {
 	config.register(new AbstractBinder() {
 		@Override
 		@Override
 		protected void configure() {
 		protected void configure() {
-			bindFactory(SessionFactoryFactory.class).to(SessionFactory.class).in(
+			bindFactory(EMFactory.class).to(EntityManagerFactory.class).in(
 					Singleton.class);
 					Singleton.class);
 		}
 		}
 	});
 	});

+ 13 - 14
frameworks/Java/undertow-jersey/src/main/java/hello/JsonResource.java

@@ -1,22 +1,21 @@
 package hello;
 package hello;
 
 
-import javax.inject.*;
-import javax.ws.rs.*;
-import java.util.*;
-
 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
 
 
+import java.util.Collections;
+
+import javax.inject.Singleton;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
 @Singleton
 @Singleton
 @Path("/json")
 @Path("/json")
-public class JsonResource
-{
+public class JsonResource {
 
 
-  @GET
-  @Produces(APPLICATION_JSON)
-  public Object json()
-  {
-    Map<String, String> data = new HashMap<String, String>(1);
-    data.put("message", "Hello, World!");
-    return data;
-  }
+	@GET
+	@Produces(APPLICATION_JSON)
+	public Object json() {
+		return Collections.singletonMap("message", "Hello, World!");
+	}
 }
 }

+ 12 - 11
frameworks/Java/undertow-jersey/src/main/java/hello/PlaintextResource.java

@@ -1,16 +1,17 @@
 package hello;
 package hello;
 
 
-import javax.inject.*;
-import javax.ws.rs.*;
+import javax.inject.Singleton;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
 
 
 @Singleton
 @Singleton
 @Path("/plaintext")
 @Path("/plaintext")
-public class PlaintextResource
-{
-  @GET
-  @Produces("text/plain")
-  public String plaintext()
-  {
-    return "Hello, World!";
-  }
-}
+public class PlaintextResource {
+
+	@GET
+	@Produces("text/plain")
+	public Object plaintext() {
+		return "Hello, World!";
+	}
+}

+ 0 - 39
frameworks/Java/undertow-jersey/src/main/java/hello/SessionFactoryFactory.java

@@ -1,39 +0,0 @@
-package hello;
-
-import hello.domain.Fortune;
-import hello.domain.World;
-
-import javax.ws.rs.ext.Provider;
-
-import org.glassfish.hk2.api.Factory;
-import org.hibernate.SessionFactory;
-import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
-import org.hibernate.cfg.Configuration;
-
-@Provider
-public class SessionFactoryFactory implements Factory<SessionFactory> {
-	private final SessionFactory factory;
-
-	public SessionFactoryFactory() {
-		factory = createSessionFactory();
-	}
-
-	@Override
-	public SessionFactory provide() {
-		return factory;
-	}
-
-	@Override
-	public void dispose(SessionFactory factory) {
-		factory.close();
-	}
-
-	private static SessionFactory createSessionFactory() {
-		Configuration configuration = new Configuration().configure();
-		configuration.addAnnotatedClass(World.class);
-		configuration.addAnnotatedClass(Fortune.class);
-		StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
-		builder.applySettings(configuration.getProperties());
-		return configuration.buildSessionFactory(builder.build());
-	}
-}

+ 134 - 0
frameworks/Java/undertow-jersey/src/main/java/hello/WorldResource.java

@@ -0,0 +1,134 @@
+package hello;
+
+import hello.domain.World;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.ThreadLocalRandom;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+
+@Singleton
+@Produces(MediaType.APPLICATION_JSON)
+@Path("/db")
+public class WorldResource {
+	@Inject
+	private EntityManagerFactory emf;
+
+	@GET
+	public Object db() throws InterruptedException, ExecutionException {
+		Callable<World> callable = () -> {
+			EntityManager em = emf.createEntityManager();
+			Session session = em.unwrap(Session.class);
+			session.setDefaultReadOnly(true);
+			try {
+				return (World) session.byId(World.class).load(randomWorld());
+			} finally {
+				session.close();
+			}
+		};
+		Future<World> futureWorld = Common.EXECUTOR.submit(callable);
+		return futureWorld.get();
+	}
+
+	@GET
+	@Path("/queries")
+	public Object queries(@QueryParam("queries") String queriesParam) throws InterruptedException,
+			ExecutionException {
+		final int queries = getQueries(queriesParam);
+		final World[] worlds = new World[queries];
+
+		Callable<World[]> callable = () -> {
+			Session session = emf.createEntityManager().unwrap(Session.class);
+			session.setDefaultReadOnly(true);
+			try {
+				for (int i = 0; i < queries; i++) {
+					worlds[i] = (World) session.byId(World.class).load(randomWorld());
+				}
+				return worlds;
+			} finally {
+				session.close();
+			}
+		};
+		Future<World[]> futureWorlds = Common.EXECUTOR.submit(callable);
+		return futureWorlds.get();
+	}
+
+	@GET
+	@Path("/updates")
+	public World[] updates(@QueryParam("queries") String queriesParam) throws InterruptedException,
+			ExecutionException {
+		final int queries = getQueries(queriesParam);
+		final World[] worlds = new World[queries];
+
+		Callable<World[]> callable = () -> {
+			Session session = emf.createEntityManager().unwrap(Session.class);
+			session.setDefaultReadOnly(false);
+			Transaction txn = session.beginTransaction();
+
+			try {
+				// using write batching. See the data source properties provided
+				// in the configuration file
+
+				// 1. Read and update the entities from the DB
+				for (int i = 0; i < queries; i++) {
+					final World world = (World) session.byId(World.class).load(randomWorld());
+					world.setRandomNumber(randomWorld());
+					worlds[i] = world;
+				}
+
+				// 2. Sort the array to prevent transaction deadlock in the DB
+				Arrays.sort(worlds, Comparator.comparingInt(World::getId));
+
+				// 3. Actually save the entities
+				for (int i = 0; i < worlds.length; i++) {
+					session.persist(worlds[i]);
+				}
+
+				session.flush();
+				session.clear();
+				txn.commit();
+
+				return worlds;
+			} catch (RuntimeException e) {
+				if (txn != null && txn.isActive())
+					txn.rollback();
+				throw e;
+			} finally {
+				session.close();
+			}
+		};
+		Future<World[]> futureWorlds = Common.EXECUTOR.submit(callable);
+		return futureWorlds.get();
+	}
+
+	private static int getQueries(String proto) {
+		int result = 1;
+		try {
+			if (proto != null && !proto.trim().isEmpty()) {
+				result = Integer.parseInt(proto);
+			}
+		} catch (NumberFormatException ignored) {/* by test contract */
+		}
+
+		return Math.min(500, Math.max(1, result));
+	}
+
+	private static int randomWorld() {
+		return 1 + ThreadLocalRandom.current().nextInt(10000);
+	}
+}

+ 31 - 25
frameworks/Java/undertow-jersey/src/main/java/hello/domain/Fortune.java

@@ -1,30 +1,36 @@
 package hello.domain;
 package hello.domain;
 
 
-import javax.persistence.*;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
 
 
 @Entity
 @Entity
-public class Fortune
-    implements Comparable<Fortune>
-{
-
-  @Id
-  @GeneratedValue(strategy = GenerationType.IDENTITY)
-  public int    id;
-  public String message;
-
-  public Fortune()
-  {
-  }
-
-  public Fortune(final int id, final String message)
-  {
-    this.id = id;
-    this.message = message;
-  }
-
-  @Override
-  public int compareTo(final Fortune other)
-  {
-    return message.compareTo(other.message);
-  }
+public class Fortune implements Comparable<Fortune> {
+
+	@Id
+	@GeneratedValue(strategy = GenerationType.IDENTITY)
+	private int id;
+	private String message;
+
+	public Fortune() {
+	}
+
+	public Fortune(int id, String message) {
+		this.id = id;
+		this.message = message;
+	}
+
+	public int getId() {
+		return id;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	@Override
+	public int compareTo(Fortune other) {
+		return message.compareTo(other.message);
+	}
 }
 }

+ 21 - 7
frameworks/Java/undertow-jersey/src/main/java/hello/domain/World.java

@@ -1,14 +1,28 @@
 package hello.domain;
 package hello.domain;
 
 
-import javax.persistence.*;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
 
 
 @Entity
 @Entity
-public class World
-{
+public class World {
 
 
-  @Id
-  @GeneratedValue(strategy = GenerationType.IDENTITY)
-  public int id;
-  public int randomNumber;
+	@Id
+	@GeneratedValue(strategy = GenerationType.IDENTITY)
+	private int id;
+	private int randomNumber;
+
+	public int getId() {
+		return id;
+	}
+
+	public int getRandomNumber() {
+		return randomNumber;
+	}
+
+	public void setRandomNumber(int randomNumber) {
+		this.randomNumber = randomNumber;
+	}
 
 
 }
 }

+ 30 - 0
frameworks/Java/undertow-jersey/src/main/resources/META-INF/persistence.xml

@@ -0,0 +1,30 @@
+<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
+             http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
+	version="2.1">
+
+	<persistence-unit name="0-TFB">
+		<description>
+			The Techempower Framework Benchmarks persistence unit
+		</description>
+		<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+		<properties>
+			<property name="hibernate.cache.use_query_cache" value="false" />
+			<property name="hibernate.hbm2ddl.auto" value="none" />
+			<property name="hibernate.format_sql" value="false" />
+			<property name="hibernate.show_sql" value="false" />
+			<property name="hibernate.jdbc.batch_size" value="30" />
+			<property name="hibernate.jdbc.batch_versioned_data" value="true" />
+			<property name="hibernate.c3p0.min_size" value="256" />
+			<property name="hibernate.c3p0.max_size" value="256" />
+			<property name="hibernate.c3p0.timeout" value="1800" />
+			<property name="hibernate.c3p0.max_statements" value="2048" />
+			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
+			<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
+			<property name="hibernate.connection.url" value="jdbc:mysql://tfb-database: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&amp;useSSL=false" />
+			<property name="hibernate.connection.username" value="benchmarkdbuser" />
+			<property name="hibernate.connection.password" value="benchmarkdbpass" />
+		</properties>
+	</persistence-unit>
+</persistence>

+ 2 - 2
frameworks/Java/undertow-jersey/src/main/resources/fortunes.mustache

@@ -9,12 +9,12 @@
 <th>id</th>
 <th>id</th>
 <th>message</th>
 <th>message</th>
 </tr>
 </tr>
-{{#fortunes}}
+{{#.}}
 <tr>
 <tr>
 <td>{{id}}</td>
 <td>{{id}}</td>
 <td>{{message}}</td>
 <td>{{message}}</td>
 </tr>
 </tr>
-{{/fortunes}}
+{{/.}}
 </table>
 </table>
 </body>
 </body>
 </html>
 </html>

+ 0 - 17
frameworks/Java/undertow-jersey/src/main/resources/hibernate.cfg.xml

@@ -1,17 +0,0 @@
-<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
-<hibernate-configuration>
-  <session-factory>
-    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
-    <property name="hibernate.connection.url">jdbc:mysql://tfb-database:3306/hello_world?useSSL=false&amp;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.dialect">org.hibernate.dialect.MySQLDialect</property>
-    <property name="hibernate.cache.use_query_cache">false</property>
-    <property name="hibernate.c3p0.min_size">256</property>
-    <property name="hibernate.c3p0.max_size">256</property>
-    <property name="hibernate.c3p0.timeout">1800</property>
-    <property name="hibernate.c3p0.max_statements">2048</property>
-    <property name="hibernate.show_sql">false</property>
-    <property name="hibernate.format_sql">false</property>
-  </session-factory>
-</hibernate-configuration>

+ 30 - 0
frameworks/Java/undertow-jersey/src/main/resources/hikarycp/META-INF/persistence.xml

@@ -0,0 +1,30 @@
+<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
+             http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
+	version="2.1">
+
+	<persistence-unit name="0-TFB">
+		<description>
+			The Techempower Framework Benchmarks persistence unit
+		</description>
+		<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+		<properties>
+			<property name="hibernate.cache.use_query_cache" value="false" />
+			<property name="hibernate.hbm2ddl.auto" value="none" />
+			<property name="hibernate.format_sql" value="false" />
+			<property name="hibernate.show_sql" value="false" />
+			<property name="hibernate.jdbc.batch_size" value="30" />
+			<property name="hibernate.jdbc.batch_versioned_data" value="true" />
+			<property name="hibernate.hikari.minimumIdle" value="256" />
+			<property name="hibernate.hikari.maximumPoolSize" value="256" />
+			<property name="hibernate.hikari.idleTimeout" value="30000" />
+			<property name="hibernate.connection.provider_class" value="org.hibernate.hikaricp.internal.HikariCPConnectionProvider" />
+			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
+			<property name="hibernate.hikari.dataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" />
+			<property name="hibernate.hikari.dataSource.url" value="jdbc:mysql://tfb-database: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&amp;useSSL=false" />
+			<property name="hibernate.hikari.dataSource.user" value="benchmarkdbuser" />
+			<property name="hibernate.hikari.dataSource.password" value="benchmarkdbpass" />
+		</properties>
+	</persistence-unit>
+</persistence>

+ 0 - 16
frameworks/Java/undertow-jersey/src/main/resources/hikarycp/hibernate.cfg.xml

@@ -1,16 +0,0 @@
-<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
-<hibernate-configuration>
-  <session-factory>
-    <property name="hibernate.connection.provider_class">org.hibernate.hikaricp.internal.HikariCPConnectionProvider</property>
-    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
-    <property name="hibernate.cache.use_query_cache">false</property>
-    <property name="hibernate.show_sql">false</property>
-    <property name="hibernate.hikari.minimumIdle">256</property>
-    <property name="hibernate.hikari.maximumPoolSize">256</property>
-    <property name="hibernate.hikari.idleTimeout">30000</property>
-    <property name="hibernate.hikari.dataSourceClassName">com.mysql.jdbc.jdbc2.optional.MysqlDataSource</property>
-    <property name="hibernate.hikari.dataSource.url">jdbc:mysql://tfb-database: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&amp;useSSL=false</property>
-    <property name="hibernate.hikari.dataSource.user">benchmarkdbuser</property>
-    <property name="hibernate.hikari.dataSource.password">benchmarkdbpass</property>
-  </session-factory>
-</hibernate-configuration>