Project

General

Profile

Sample-hibernate-basic » History » Version 6

Henning Blohm, 16.09.2012 19:31

1 1 Henning Blohm
h1. A plain Hibernate on Z2 sample
2 2 Henning Blohm
3 3 Henning Blohm
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). 
4 4 Henning Blohm
5 5 Henning Blohm
This sample is stored in the repository "z2-samples.hibernate.basic":http://redmine.z2-environment.net/projects/z2-samples/repository/z2-samples-hibernate-basic. 
6
7
h2. Prerequisites
8
9
You need the *z_tx_tests* database on a local MySQL database system. Start the MySQL client as the root user and run:
10
11
<pre><code class="SQL">
12
create database z_tx_tests;
13
grant all on z_tx_tests.* to tx@localhost identified by 'tx';
14
</code></pre>
15
16
h2. Run it
17
18 6 Henning Blohm
Like all samples, also this sample can be run as in [[How to run a sample]]. If you have the database, the fastest way to verify whether it runs is:
19 5 Henning Blohm
20
<pre><code class="ruby">
21
mkdir install
22
cd install 
23
git clone -b master http://git.z2-environment.net/z2-base.core
24
git clone -b master http://git.z2-environment.net/z2-samples.hibernate-basic
25
26
# on Linux / Mac OS:
27
cd z2-base.core/run/bin
28
./gui.sh
29
30
# on Windows:
31
cd z2-base.core\run\bin
32
gui.bat
33
</code></pre>
34
35
h2. Details
36
37 4 Henning Blohm
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.
38
39
If everything would happen inside one module, the structure could be kept even simpler.