Create a new TestSetup
Java class in a package named com.sap.hana.hibernate.tutorial.setup
(either using a right-click on the project and choose New -> Class or use the File -> New -> Class menu bar), then paste the following content:
package com.sap.hana.hibernate.tutorial.setup;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
public class TestSetup {
public static void main(String[] args) {
try {
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("Tutorial");
EntityManager entityManager = entityManagerFactory.createEntityManager();
Query nativeQuery = entityManager.createNativeQuery("SELECT * FROM DUMMY");
String result = String.valueOf(nativeQuery.getSingleResult());
if ("X".equals(result)) {
System.out.println("SUCCESS!");
} else {
throw new RuntimeException("Wrong result!");
}
entityManager.clear();
entityManager.close();
} catch (Exception e) {
e.printStackTrace();
}
System.exit(0);
}
}
Save the class file.
Run the application by right-clicking the class file and choosing Run As -> Java Application or click on the
icon.
You should see the following output log in your console:
nov. 07, 2017 8:30:29 AM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
INFO: HHH000204: Processing PersistenceUnitInfo [
name: Tutorial
...]
nov. 07, 2017 8:30:29 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.2.12.Final}
nov. 07, 2017 8:30:29 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
nov. 07, 2017 8:30:29 AM org.hibernate.spatial.integration.SpatialService <init>
INFO: HHH80000001: hibernate-spatial integration enabled : true
nov. 07, 2017 8:30:29 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
nov. 07, 2017 8:30:29 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
nov. 07, 2017 8:30:29 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001005: using driver [com.sap.db.jdbc.Driver] at URL [jdbc:sap://rhhxehost:39015]
nov. 07, 2017 8:30:29 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001001: Connection properties: {user=SYSTEM, password=****}
nov. 07, 2017 8:30:29 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001003: Autocommit mode: false
nov. 07, 2017 8:30:29 AM org.hibernate.engine.jdbc.connections.internal.PooledConnections <init>
INFO: HHH000115: Hibernate connection pool size: 5 (min=1)
nov. 07, 2017 8:30:29 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.HANAColumnStoreDialect
nov. 07, 2017 8:30:29 AM org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl useContextualLobCreation
INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
nov. 07, 2017 8:30:30 AM org.hibernate.tool.schema.internal.SchemaCreatorImpl applyImportSources
INFO: HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@14bdbc74'
Hibernate:
SELECT
*
FROM
DUMMY
SUCCESS!