Object-relational mapping (ORM, O/RM, and O/R mapping) in computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database"
that can be used from within the programming language. There are both
free and commercial packages available that perform object-relational
mapping, although some programmers opt to create their own ORM tools.
Hibernate is a ORM database Tables Java Classes implies Rows in a Table Java Objects
Step1:
Hibernate is a ORM database Tables Java Classes implies Rows in a Table Java Objects
Step1:
- Download and install hibernate Plugin from here along with many handy tools for JBoss
- Create a Web Dynamic Project or you can go with Plain Java Project.
- Project New Other Hibernate Configuration File
- Select your project/JavaSource
- Fill in details about your database
- Make sure you select Checkbox Create a console configuration
- Finish
Code (SQL Server):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="">
<property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="hibernate.connection.password">****</property>
<property name="hibernate.connection.url">jdbc:sqlserver://servername;databaseName=YourDatabase</property>
<property name="hibernate.connection.username">bhauser</property>
<property name="hibernate.default_catalog">Make sure You know your Catlog for SQL Server</property>
<property name="hibernate.default_schema">SchemaName</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
</session-factory>
</hibernate-configuration>
Step 4:- Project Properties Project Facets Enable JPA Apply Ok
- It will take some time to install JPA
- In Persistant management class Select Radio Button "Discover annotated class automatically"
Step 5:
This step is going to be setting up hibernate console. From Step 3 you already have hibernate console for your project.
- Change Perspective to Hibernate
- Now near you project explorer you must see Hibernate Configuration Pane.
- Right Click on your Project configuration file and Edit
All set to generate dynamic entities! :)
No comments:
Post a Comment