Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
- <hibernate-mapping>
- <class name="entity.Employee" table="EMP">
- <id name="employeeId" column="EId">
- <generator class="assigned"></generator>
- </id>
- <property name="employeeName" column="Name"></property>
- <property name="employeeAddress" column="Address"></property>
- <property name="salary"></property>
- </class>
- </hibernate-mapping>
- ***********************************************************************
- package entity;
- import org.hibernate.Session;
- import org.hibernate.SessionFactory;
- import org.hibernate.Transaction;
- import org.hibernate.cfg.Configuration;
- public class Test {
- public static void main(String[] args) {
- Configuration configuration = new Configuration().configure();
- SessionFactory factory=configuration.buildSessionFactory();
- Session session = factory.openSession();
- Transaction transaction = session.beginTransaction();
- Employee employee = new Employee(122,"Om","Ernakulam",37000);
- session.save(employee);
- //Employee employee = new Employee();
- //employee.setEmployeeId(122);
- //session.delete(employee);
- transaction.commit();
- System.out.println("DATA DEL");
- }
- }
- ********************************************************************
- <?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>
- <property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
- <property name="connection.url">jdbc:oracle:thin:@127.0.0.1:1521:xe</property>
- <property name="connection.username">system</property>
- <property name="connection.password">admin</property>
- <property name="dialect">org.hibernate.dialect.OracleDialect</property>
- <property name="show_sql">false</property>
- <property name="hibernate.hbm2ddl.auto">update</property><!-- create/update -->
- <!-- Mapping files -->
- <mapping resource="employee.hbm.xml"/>
- </session-factory>
- </hibernate-configuration>
Add Comment
Please, Sign In to add comment