solidDB Help : Samples : solidDB with Hibernate sample
  
solidDB with Hibernate sample
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:
common-collections.jar
dom4j.jar
javassist.jar
jta.jar
slf4j-api.jar
slf4j-jdk.jar
hibernate3.jar
hibernate-jpa.jar
Note The sample configuration is simplified if you can copy all the jars to the same directory.
3 Edit the makefile, and adjust the paths to match the locations and versions of the jars located in the previous step.
4 Use the src\hibernate.cfg.xml file to define the following configuration properties for solidDB:
solidDB JDBC connection string (URL):
<property name="connection.url">jdbc:solid://localhost:2315</property>
User name and password for the solidDB database:
<property name="connection.username">dba</property>
<property name="connection.password">dba</property>
solidDB JDBC Driver class:
<property name="connection.driver_class">solid.jdbc.SolidDriver</property>
solidDB Hibernate Dialect:
<property name="dialect">org.hibernate.dialect.SolidSQLDialect</property>
Do not print Hibernate SQL operations taking place:
<property name="hibernate.show_sql">false</property>
Automatically create the table for the object:
<property name="hbm2ddl.auto">create</property>
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.
Go up to
Samples