Headline

Object-Relational mapping with Technology:Hibernate

Implementations

Contribution:hibernate is a technical prerequisite for this implementation, since it holds the hibernate jars.

The given implementation is also a variation of hibernate. The variation is concerned with object model and relational schema details. That is, this project's object model is mapped to a relational schema, which represents the company structure in a compositional way, while hibernate's relational schema uses backward references.

Motivation

An object model for companies is provided, as well as classes to total and cut salaries. This is, we apply a basic style of OO programming. Instances the company model are persisted by making use of the Technology:Hibernate technology. To that end the O/R mapping is realized by making use of Language:XML-mapping files for departments, employees, subunits and persons.

Architecture

Package org.softlang.om holds the java object model for Feature:Hierarchical company and the xml-mapping files. org.softlang.hibernate provides functionality to Feature:Total and Feature:Cut salaries. This package also hosts Init.java which tells hibernate to create tables; also test cases (see below) and and HibernateConnectivity.java to easily load and save company objects. This class uses the SessionFactory provided by HibernateUtil.java in org.softlang.util. The folder scripts contains sql-scripts to create tables (extracted from the hibernate log), populate data and to drop tables. Hibernate configuration files (see below) can be found in the project's root folder.

Usage

Steps of a typical demo:

  • Make sure you start from an initial distribution.
  • Build the project with Eclipse.
(The following steps are explained in detail below.)
  • Start the HSQL database server.
  • Run org/softlang/hibernate/Init.java to create tables.
  • Run the database monitor and populate the tables with scripts/PopulateTables.
  • Patch hibernate.cfg.xml to disable "drop and re-recreate".
  • Run org/softlang/hibernate/Tests.java.
How to start the database server:
  • Start it from the command line.
  • Go to the data dir of the distribution.
  • Run the following command:
    • > java -classpath ../../hibernate/lib/hsqldb.jar org.hsqldb.Server
    • You can also send it to the background if you like.
You can also go to the root dir and run a "make start-db".

How to create new tables:

  • Run Init.java in org.softlang.hibernate.
How and why to start the database monitor:

  • Start it from the command line.
  • Run the following command:
    • > java -classpath ../hibernate/lib/hsqldb.jar org.hsqldb.util.DatabaseManagerSwing
    • You can also send it to the background if you like.
You can also go to the root dir and run a "make start-gui".
  • When the GUI pops up, make sure to select "HSQL Database Engine Server".
  • If you had performed Main already, you see the tables of the app.
  • Populate these tables:
    • Open scripts/PopulateTables (File -> Open Script)
    • Press "Execute SQL"
How and why to patch hibernate.cfg.xml?

You can edit that XML file in Eclipse. It is the configuration that is used for Hibernate for persistency. Upon the first use the EventManager the database must be initialized. Hence it says:

<property name="hbm2ddl.auto">create</property>
Subsequently, we want to keep all data. Hence the line should be commented out.

How to test:

  • Run Tests.java in org.softlang.hibernate.

There are no revisions for this page.

User contributions

    This user never has never made submissions.

    User edits

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.