// Path: src/main/java/org/sfm/benchmark/db/jmh/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// 
// 	@Param(value="MOCK")
// 	public DbTarget db;
// 
// 	public DataSource dataSource;
// 	
// 	@Setup
// 	public void init() throws SQLException, NamingException {
// 		dataSource = ConnectionHelper.getDataSource(db);
// 		
// 		if (db != DbTarget.MOCK) {
// 			Connection conn = dataSource.getConnection();
// 			try {
// 				ConnectionHelper.createTableAndInsertData(conn);
// 			} finally {
// 				conn.close();
// 			}
// 		}
// 	}
// 	
// 	public Connection getConnection() throws SQLException {
// 		return dataSource.getConnection();
// 	}
// }
// 
// Path: src/main/java/org/sfm/benchmark/db/jmh/DbTarget.java
// public enum DbTarget {
// 	MOCK {
// 		@Override
// 		public SQLDialect getSqlDialect() {
// 			return SQLDialect.MYSQL;
// 		}
// 	}, HSQLDB {
// 		@Override
// 		public SQLDialect getSqlDialect() {
// 			return SQLDialect.HSQLDB;
// 		}
// 	}, MYSQL {
// 		@Override
// 		public SQLDialect getSqlDialect() {
// 			return SQLDialect.MYSQL;
// 		}
// 	};
// 
// 	public abstract SQLDialect getSqlDialect();
// }
// 
// Path: src/main/java/org/sfm/benchmark/db/jmh/LimitParam.java
// @State(Scope.Benchmark)
// public class LimitParam {
// 	@Param(value={"1", "10", "100", "1000", "10000", "100000", "1000000"})
// 	public int limit;
// }


import java.sql.SQLException;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.sfm.benchmark.db.jmh.ConnectionParam;
import org.sfm.benchmark.db.jmh.DbTarget;
import org.sfm.benchmark.db.jmh.LimitParam;
package org.sfm.benchmark.db.hibernate;



@State(Scope.Benchmark)
public class HibernateStatefullBenchmark {

	private SessionFactory sf;
	
	@Param(value="MOCK")
	DbTarget db;
	
	boolean enableCache = false;
	
	
	@Setup
	public void init() throws Exception  {
		ConnectionParam connParam = new ConnectionParam();
		connParam.db = db;
		connParam.init();
		sf = HibernateHelper.getSessionFactory(enableCache, connParam);
	}

	@Benchmark
// Path: src/main/java/org/sfm/benchmark/db/jmh/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// 
// 	@Param(value="MOCK")
// 	public DbTarget db;
// 
// 	public DataSource dataSource;
// 	
// 	@Setup
// 	public void init() throws SQLException, NamingException {
// 		dataSource = ConnectionHelper.getDataSource(db);
// 		
// 		if (db != DbTarget.MOCK) {
// 			Connection conn = dataSource.getConnection();
// 			try {
// 				ConnectionHelper.createTableAndInsertData(conn);
// 			} finally {
// 				conn.close();
// 			}
// 		}
// 	}
// 	
// 	public Connection getConnection() throws SQLException {
// 		return dataSource.getConnection();
// 	}
// }
// 
// Path: src/main/java/org/sfm/benchmark/db/jmh/DbTarget.java
// public enum DbTarget {
// 	MOCK {
// 		@Override
// 		public SQLDialect getSqlDialect() {
// 			return SQLDialect.MYSQL;
// 		}
// 	}, HSQLDB {
// 		@Override
// 		public SQLDialect getSqlDialect() {
// 			return SQLDialect.HSQLDB;
// 		}
// 	}, MYSQL {
// 		@Override
// 		public SQLDialect getSqlDialect() {
// 			return SQLDialect.MYSQL;
// 		}
// 	};
// 
// 	public abstract SQLDialect getSqlDialect();
// }
// 
// Path: src/main/java/org/sfm/benchmark/db/jmh/LimitParam.java
// @State(Scope.Benchmark)
// public class LimitParam {
// 	@Param(value={"1", "10", "100", "1000", "10000", "100000", "1000000"})
// 	public int limit;
// }


// Path: src/main/java/org/sfm/benchmark/db/hibernate/HibernateStatefullBenchmark.java
import java.sql.SQLException;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.sfm.benchmark.db.jmh.ConnectionParam;
import org.sfm.benchmark.db.jmh.DbTarget;
import org.sfm.benchmark.db.jmh.LimitParam;

package org.sfm.benchmark.db.hibernate;



@State(Scope.Benchmark)
public class HibernateStatefullBenchmark {

	private SessionFactory sf;
	
	@Param(value="MOCK")
	DbTarget db;
	
	boolean enableCache = false;
	
	
	@Setup
	public void init() throws Exception  {
		ConnectionParam connParam = new ConnectionParam();
		connParam.db = db;
		connParam.init();
		sf = HibernateHelper.getSessionFactory(enableCache, connParam);
	}

	@Benchmark
	public void testQuery(LimitParam limit, final Blackhole blackhole) throws Exception {