Posts

Showing posts with the label Maven

Hibernate many to many mapping example using annotation

Image
In this post we are going to show you how to use Many-To-Many association in hibernate using annotation. For One-To-Many association example you can traverse my previous post One-To-Many association example using annotation . Many-To-Many association means, One or more row(s) of a table are associated one or more row(s) in another table. For example an employee may assigned with multiple projects, and a project is associated with multiple employees. In this post we are going to show you the same employee and project association using annotation, below are the listed table for our this project. Employee table: employee_id first_name last_name doj 101 Tony Jha 2014-08-28 102 Zeneva S. Humphrey 2014-07-04 Project table: project_id project_name start_date exp_end_date 101 MARS 2013-01-01 2015-08-28 102 SBA 2014-10-02 2016-07-04 Employee_Proj table...

Hibernate 4 maven one to many mapping example using annotation

Image
We have already seen the implementation of one-to-one association in hibernate . In this post we are going to implement One-To-Many association mapping example using annotation. For One-To-Many association example using hbm.xml file see our previous article One-To-Many example using hbm.xml   One to many association means each row of a table can be related to many rows in the relating tables. For example, we have an author and book table, we all know that a particular book is written by a particular author. An author of a book is always one and only one person, co-author of a book may be multiple but author always only one. So many books can be written by an author, here many books an author relationship is one-to-many association example. an author has many books that is. 1------------------------* books( one-to-may association) Here is the example of author and book table for our One-To-Many association example. Author table: author_id first_name last_na...

Hibernate 4 Mysql Maven Java 7 Eclipse CRUD example using annotation

Image
Again,we are going to create a step by step very basic hibernate 4 annotation based CRUD application using maven . We have already created the same application without using maven here . In this project we have a single table called user and we are going to perform crud operations on the user table data only. Technologies & Tools we are using here: JDK 7 Hibernate 4.0 MySql 5.5 Eclipse Juno 4.2 Maven 3.2.2 Note : please make sure that maven plugin is installed in your eclipse. Overview of the project structure: Main Objects of this project are: pom.xml hibernate.cfg.xml Annotated Entity class Database Here is a user table description with very few columns: 1. Create table query: /*Table structure for table `user` */ DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_name` varchar(50) DEFAULT NULL, `password` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1; ...