You have a privilege to create a quiz (QnA) related to this subject and obtain creativity score...
Hibernate is one of the first and one of the best Object-Relational Mapping (ORM) frameworks.
The main features:
-Uses Object-Oriented (OO) query language called Hibernate Query Language (HQL)
-Uses objects instead of tables and fields instead of columns
-Provides object-to-relational mapping for most DBs
-Separates data layer from business logics
-Uses DB connection info to retrieve DB schema
-Generates Data Access Objects (DAO) beans with data fields mapping table columns
-Generates Insert/Update/Delete/Select statements for DB tables
For example, using Hibernate we would create the class Accounts to map this class to the Accounts table.
public class Accounts {
// data
private String email;
private String password;
private String enabled;
// get and set methods for each variable
// usually done with Eclipse – right mouse click on the Eclipse source page – SOURCE – Generate Getters and Setters
}
Then, we would create the mapping file:
We can save this file in the resources folder of the project as Accounts.hbm.xml and provide a reference to this file in Hibernate configuration, which illustrated below as hibernate.cfg.xml file.
oracle.jdbc.driver.OracleDriver jdbc:oracle:thin:@localhost:1521:its its its
10
org.hibernate.dialect.OracleDialect
thread
Was it clear so far?
Note that this configuration file includes all details related to the database in the SessionFactory scope. SessionFactory is responsible for a specific database. For several databases, we would use several configurations.
Property elements include connection data, size of the connection pool (10 simultaneous connections), and point to a specific dialect, in this case, Oracle, to properly address data types and more database
There is the line that enables Hibernate's automatic session management. And the last line points to the Accounts mapping file. We would also save this file in the project - resources directory hibernate.cfg.xml.
In our Java source we will be able to handle data with Java code similar to the example below. Hibernate provides necessary SQL for us behind the scene.
<br/>public class Accounts {
<br/> // data
<br/> private String email;
<br/> private String password;
<br/> private String enabled;
<br/> // get and set methods for each variable
<br/> // usually done with Eclipse – right mouse click on the Eclipse source page – SOURCE – Generate Getters and Setters
<br/>}
<br/>
We can save this file in the resources folder of the project as Accounts.hbm.xml and provide a reference to this file in Hibernate configuration, which illustrated below as hibernate.cfg.xml file.
Was it clear so far?
onclick="window.location.href='/BASE/jsp/demo.jsp?checkFlavor=itsp&issueID=56&intro=general&group=aitu&ur=f'">
Note that this configuration file includes all details related to the database in the SessionFactory scope. SessionFactory is responsible for a specific database. For several databases, we would use several configurations.
Property elements include connection data, size of the connection pool (10 simultaneous connections), and point to a specific dialect, in this case, Oracle, to properly address data types and more database
There is the line that enables Hibernate's automatic session management. And the last line points to the Accounts mapping file. We would also save this file in the project - resources directory hibernate.cfg.xml.
In our Java source we will be able to handle data with Java code similar to the example below. Hibernate provides necessary SQL for us behind the scene.