Sample-hibernate-basic » History » Revision 5
Revision 4 (Henning Blohm, 16.09.2012 16:03) → Revision 5/32 (Henning Blohm, 16.09.2012 19:30)
h1. A plain Hibernate on Z2 sample
Note that Hibernate is used in other samples as well, such as [[Sample-jta-plain]], [[Sample-jta-spring]], and others. This sample shows the minimal things to do to use Hibernate as an implementation of the Java Persistence API ("JPA":http://de.wikipedia.org/wiki/Java_Persistence_API).
This sample is stored in the repository "z2-samples.hibernate.basic":http://redmine.z2-environment.net/projects/z2-samples/repository/z2-samples-hibernate-basic.
h2. Prerequisites
You need the *z_tx_tests* database on a local MySQL database system. Start the MySQL client as the root user and run:
<pre><code class="SQL">
create database z_tx_tests;
grant all on z_tx_tests.* to tx@localhost identified by 'tx';
</code></pre>
h2. Run it
If you have the database, the fastest way to verify whether it runs is:
<pre><code class="ruby">
mkdir install
cd install
git clone -b master http://git.z2-environment.net/z2-base.core
git clone -b master http://git.z2-environment.net/z2-samples.hibernate-basic
# on Linux / Mac OS:
cd z2-base.core/run/bin
./gui.sh
# on Windows:
cd z2-base.core\run\bin
gui.bat
</code></pre>
h2. Details
The assumption of this example is that of a re-use domain module that implements a "Thingy Repository" and is used from a web application that is in another module.
If everything would happen inside one module, the structure could be kept even simpler.