Tag: Hibernate
Implement many to many relationship in hibernate
1.72K Views0 Comments0 Likes
Hibernate Many-to-many Relationships - Many to many example in Hibernate. In this example we have used xml metadata. Now we will learn many-to-many relationships. Let's try many-to-many example. The many-to-many ta...
Implement one to one mapping with Hibernate
1.30K Views0 Comments0 Likes
A one-to-one association is similar to many-to-one association with a difference that the column will be set as unique. For example an address object can be associated with a single employee object.... Let us devel...
Full HD Hibernate tutorial series [part 1] – Install Eclipse Hibernate and Derby database
1.96K Views0 Comments0 Likes
1. Install Eclipse and database Download JDK and install it Download Eclipse from eclipse.organd extract the zip file. Download db-derby database from Apache Derby website Download Hibernate from Hibernate.o...
Full HD Hibernate tutorial series [part 2] – Configure Eclipse with Hibernate
1.31K Views0 Comments0 Likes
1. Create a "User library" Using top menu click "Window" -> "Preferences" -> Type user -> "User Librairies" -> "New" Click "Add Jar" -> "DerbyClient.jar" Click "Add Jar" -> Select Hibernate J...
Full HD Hibernate tutorial series [part 3] – Write hibernate.cfg.xml file
1.35K Views0 Comments0 Likes
Your hibernate.cfg.xml file should look like this <property name="hibernate.connection.driver_class"> org.apache.derby.jdbc.ClientDriver </property> <property name="hibernate.connection.url"> jdbc:...
Full HD Hibernate tutorial series [part 4] – Create Employee class
1.24K Views0 Comments0 Likes
The Employee class should look like this @Entity public class Employee{ private int empId; private String empName; @Id public int getEmpId(){ return empId; } public void setEmpId(int empId){ ...
Full HD Hibernate tutorial series [part 5] – Write a TestEmployee test class
1.23K Views0 Comments0 Likes
public class TestEmployee{ public static void main(){ AnnotationConfiguration conf = new AnnotationConfiguration5-, conf.addAnnotatedClass(Employee.class); new SchemaExport(conf).create(true, true); } }
Full HD Hibernate tutorial series [part 6 ] – Create your own Schema
1.17K Views0 Comments0 Likes
Add this line to your hibernate.cfg.xml file <property name="hibernate.default_schema"> TESTSCHEMA <property> Using SQL scrapbook, execute this statement CREATE SCHEMA testSchema;
Full HD Hibernate tutorial series [part 7] – Insert data into database
1.48K Views0 Comments0 Likes
public class TestEmployee{ public static void main(){ AnnotationConfiguration conf = new AnnotationConfiguration5-, conf.addAnnotatedClass(Employee.class); new SchemaExport(conf).create(true, true); ...
Full HD Hibernate tutorial series [part 8] – Questions and answers about Hibernate
1.05K Views0 Comments0 Likes
What are the uses of @Entity and @Id tag? @Entity annotation indicates that the class should persist to the database. @Id annotation represents a unique primary key How do you tell Hibernate which classes are to ...
Full HD Hibernate tutorial series [part 9] – More annotations
1.18K Views0 Comments0 Likes
How to give a custom name of a table? @Table(name="myTableName") How to give a custom name of a column? @Column(name="myColumnName") How to prevent an attribute in a class from being saved into database table? @T...
Full HD Hibernate tutorial series [part 10] – Add a primary key
975 Views0 Comments0 Likes
How to add a UNIQUE field? @GeneratedValue //It generates a unique value How to add a UNIQUE primary key field and make it auto-complete? @GeneratedValue(strategy=GenerationType.AUTO) //It generates a uni...