Skip to content
Eşref ÖZTÜRK edited this page Jul 4, 2014 · 1 revision

ABOUT

This project is prepared to serve as a sample application for Hazelcast, the leading open source in-memory data grid . Here, Hazelcast's use case is Hibernate.

Prerequisites

You should have installed Apache Maven(http://maven.apache.org/download.cgi) and MySQL Server(http://dev.mysql.com/downloads/mysql/) on your system.

It would be great if you also have installed Python 2x(https://www.python.org/downloads/) on your system.

How to Run Sample Application

  1. create database named "hibernate" using the following command after replacing USERNAME and PASSWORD with yours:
mysql -u USERNAME -pPASSWORD -e 'create database hibernate;'
  1. create table named "EMPLOYEE" using the following command after replacing USERNAME and PASSWORD with yours:
mysql -u USERNAME -pPASSWORD -D hibernate -e 'create table EMPLOYEE ( id INT NOT NULL auto_increment, first_name VARCHAR(20) default NULL, last_name  VARCHAR(20) default NULL, salary INT default NULL, PRIMARY KEY (id) );'
  1. clone the repository to your local using:
git clone https://github.com/hazelcastInternsSummer14/hibernate4.git
  1. go to "hibernate4" folder

  2. change "hibernate.connection.username" and "hibernate.connection.password" fields in "src/main/resources/hibernate.cfg.xml" file according to your mysql configurations

  3. run:

mvn compile
  1. Create a hazelcast instance by running:
mvn exec:java -Dexec.mainClass="Hz"
  1. After running the following code in different terminal, you can add or delete employees. Start with writing help in the application:
mvn exec:java -Dexec.mainClass="ManageEmployee"
  1. add some employees but do not commit. After creating second hazelcast instance, shutdown first instance. Even now you should be able to commit you changes to database. You can see the employees in the database using:
mysql -u USERNAME -pPASSWORD -D hibernate -e 'select * from EMPLOYEE;'
  1. You can also edit "src/main/resources/hazelcast.xml" file using "src/main/resources/hazelcast_conf.py" script.
Clone this wiki locally