Вы находитесь на странице: 1из 2

1. pojo class/ persistent class/ bean class(.

java file)
2.Hypernet mapping file(
3. hypernat configuration file(xml file)
4. test class file(.java file)

-> pojo class


pojo class consists of seters, getters

-> Hypernet configuration file:


3 config of 3 properties
1. connection properties
eg: url, username, password
2. Hypernet properties
it is which properties we are using and which database we are using.

3. Mapping file properties:

-> test class file:

-----------------------------------------------------------------------------------
hypernet rar files....
new > class(employee class) (form.klu package) > finish.
------------
employee.class
-------------
private int empId;
private String empName;
private String empDesig;
private double empSal;

// souce > setters and getters > generate

public int getEmpId(){


return empId;
" " " " "
-----------------------------------------------------------------------------------
--
project > other > xml file(employee.html.xml)
-----------------
employee.html.xml
-----------------
hypernet 3.jar > ory.hypernet > hybernet mapping 3.0 > configuration
copy the 3,4,5 in hibernet mapping 3.0 and paste it
<hybernate-mapping>
<class table = "emps34" name = "com.klu.Employee">
<id name = "empId">
<property name = "empDesig" column = "Designation" / >
<property name = "empSal" column "Salary" />

</class>
</hibermap>

-----------------------------------------------------------------------------------
--
src > other > xml file (hibernet.cmg.xml)
copy and paste the same 3 lines from the previous xml file..fadhi
------------
<hibernate-configuration>
<session-factory>
<!-- Connection Properties -->
<property name =
"connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name = "connection.url">jdbc:oracle:thin:@localhost:1521:xe"</property>
<property name= "connection.username">system</property>
<property name= "connection.password">manager</property>
<!--Hibernate properties -->
<property name ="dialect">org.hibernate.dialect.OracleDriver</property>
<property name = "hbm2ddl.auto">insert</property>
<property name= "show_sql">true</property>
<! -- Mapping file Configuration -->

<mapping resource = "Employee.hbm.xml" />

</session-factory>
<hibern-config>
--------------------------------------------------------------------------------
project > class (employee) >
--------------

-----------
public static void main(String args[]){

Configuration cfg = new Configuration();


cfg.configure(); //cfg.onfigure("hibernate.cfg.xml")
SessionFactory sf = cfg.buildSessionFactory();
Session s = sf.openSession();

Employee e = new Employee();


e.setEmpId(4755);
e.setEmpName("sunil");
e.setEmpDesig("Asst. Prof");
e.setEmpsal(100000);
s.save(e);

s.beginTransaction().comit();
s.close();
sf.close();

Вам также может понравиться