InterviewSolution
| 1. |
What is the difference between get() and load() method? |
|
Answer» Every entity in Hibernate has to have a field which MAPS to the primary key of a table in a database. Such a field is identified by the @Id annotation. Such a field is also known as the identifier field. Identifiers are of two types: Simple Identifiers and Generated Identifiers. Simple Identifiers: This is the most straightforward way of mapping. The mapping is done by using the @Id annotation. Simple identifiers map to a single property of the below types:
Let us look at a small example: @Entity publicclassStudent { @Id privatelongstudentId; //constructors, getters, setters }Generated Identifiers: When the primary key values have to be generated automatically, @GeneratedValue annotation is added. Generated identifiers are of 4 types:
|
|