Skip to main content

One to One Relationship (Hibernate - Annotations)

This project include how to build a one to one relationship with hibernate annotations.




This app used

1 Maven
2 Hibernate
3 J2SE
4 Mysql

Database Design


This is final project structure

So we can start the project with download dependencies with Apache Maven, So for do it we have to change pom file like below. Then maven will download all the dependencies to your project easily.

Ok now we are ready to code the project so first we have to do is create data model objects (VO-Value Objects).



!!!Important Notes : When we add mappedby value in to onetoOne main table must be same name of second tables Primary keys value (In this example "stockVO")

Ok now all set Now we have to create HIbUtil and Hibernate configurations xml to the project. 

This HIbUtil Class is same for every hibernate project , So we have to do is add our VO classes as hibernate configurations. So add VO classes like this.

This code lines have to add to hib util file below "config.configure("hibernate.cfg.xml");" Ok now we have to create our hibernate.cfg.xml file in the project. Ok now we have to run this app with java main class. Run it :) Thats all

Comments

Popular posts from this blog

Sample Hibenate Util - For JPA

This is for using in hibernate annotations

Simple Login With Struts2 + Hibernate 3.0 + Maven

This tutorial includes how to create simple login with Struts2 with hibernate database connectivity. :) Also i need to say i used maven for manage dependencies and eclipse Juno EE verison for developments with Mysql database..