The goals are to:
- Design and develop a command line application to demonstrate interactivity with a database using Hibernate
- Be able to retrieve an object using Hibernate
- Be able to retrieve related objects (one-to-many collection mapping)
- Be able to insert records with Hibernate
- Be able to update records with Hibernate
- Be able to delete records with Hibernate
Technologies, Tools, and Resources used:
- Java 1.7
- Oracle SQL Developer 3.1
- Cisco VPN Client (to connect to Swinburne VPN for DB access)
- NetBeans IDE 7.2
- Hibernate 4.1.7
- Ensure all technologies/tools utilised in Spike 3 are installed
- Installation of NetBeans IDE to code Java command line application in
- Ensure database connectivity
- Creation and Testing of Hibernate XML configuration file
- Creation and Testing of Hibernate Execution Class
- Creation and Testing of Cinema & Classification Classes
- Ensure data is being altered correctly through the use of SQL Developer
What we found out:
Hibernate is an extremely useful ORM tool to provide assistance at the business layer of data use. It saves wasted hours attempted on manually developing SQL code to insert objects into a Database, by auto generating code according to the way Hibernate is configured.
By using a configuration file, Hibernate automatically generates tables and configures all attributes for the table according to the values that are inserted into the database.
Hibernate truly shows how effective it can really be toward Object-Relational Mapping, when it needs to deal large quantities of data that need to be inserted into a database, as it can easily accommodate for the slight differences in data types when inserting into a database, as opposed to having to manually alter an SQL insert query and parse data before it is in the correct format to be inserted into a database.
In the case of the Cinema Ticketing System, Hibernate allows easy management of mapping Movies to Categories & Classifications, and more importantly, the linking of a Transaction to all other connecting tables to provide specific information regarding the sale of a movie ticket.
- Incorrect configuration of Hibernate will result in errors when dealing with data that you wish to manage in a specific way.
- Hibernate is slower than just using JDBC as Hibernate is constantly generating SQL queries in the background.
- Great to use for applications that manages a vast amount of data that is constantly being Inserted, Updated or Deleted.