This sample demonstrates how to set up Hibernate with solidDB.
The files for the sample are located in the soliddb-installdir\samples\hibernate directory.
Notes
▪ To run the sample, you must install JDK 1.7 or later and set the PATH and CLASSPATH settings for the Java compiler.
▪ You must have Hibernate 3.5.1 or later installed.
For general information about running the samples, see Samples.
The sample application creates a connection between Hibernate and solidDB, creates a table called CUSTOMER, and inserts data into the table. The sample includes the following components:
▪ build.xml: Ant build file (alternative to makefile)
▪ makefile: make file for starting the solidDB database and executing the sample script
▪ runme: batch file for running the sample
▪ run\: solidDB working directory where the database is created (contains solid.ini and license file)
▪ src\hibernate.cfg.xml: configuration file for Hibernate
▪ src\customer.hbm.xml: Hibernate mapping file that defines the mapping between the Java class and the database table
▪ src\main\Customer.java: Java Class to be mapped to the database table
▪ src\main\Main.java: the main class for the application
▪ dialect\SolidSQLDialect.java: source for solidDB SQL dialect for Hibernate (provided as-is)
The sample also uses the SolidSQLDialect.jar file that is located in the jdbc directory in your solidDB installation directory.
Running the sample
Complete the following steps to prepare your environment and run the sample:
1 In your Hibernate environment, check that the lib\required directory includes the slf4j-jdk.jar file.
Note If the slf4j-jdk.jar file is not included, the file can be downloaded from the SLF4J web site (www.slf4j.org).
2 In your Hibernate environment, make a note of the directory that contains each of the following jar files and the version associated with each jar file:
▪ Mapping between the POJO and the database table CUSTOMER:
<mapping resource="customer.hbm.xml"/>
5 Run the sample by running the runme script (runme.bat in Windows), which compiles the sample application, starts a solidDB server, and runs the sample application.