Guest User

Untitled

a guest
Aug 7th, 2017
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
  3.  
  4. <hibernate-mapping>
  5. <class name="entity.Employee" table="EMP">
  6. <id name="employeeId" column="EId">
  7. <generator class="assigned"></generator>
  8. </id>
  9. <property name="employeeName" column="Name"></property>
  10. <property name="employeeAddress" column="Address"></property>
  11. <property name="salary"></property>
  12.  
  13. </class>
  14. </hibernate-mapping>
  15. ***********************************************************************
  16. package entity;
  17.  
  18. import org.hibernate.Session;
  19. import org.hibernate.SessionFactory;
  20. import org.hibernate.Transaction;
  21. import org.hibernate.cfg.Configuration;
  22.  
  23. public class Test {
  24.  
  25. public static void main(String[] args) {
  26. Configuration configuration = new Configuration().configure();
  27. SessionFactory factory=configuration.buildSessionFactory();
  28. Session session = factory.openSession();
  29. Transaction transaction = session.beginTransaction();
  30.  
  31. Employee employee = new Employee(122,"Om","Ernakulam",37000);
  32. session.save(employee);
  33. //Employee employee = new Employee();
  34. //employee.setEmployeeId(122);
  35. //session.delete(employee);
  36. transaction.commit();
  37. System.out.println("DATA DEL");
  38.  
  39. }
  40.  
  41. }
  42. ********************************************************************
  43. <?xml version="1.0" encoding="UTF-8"?>
  44. <!DOCTYPE hibernate-configuration PUBLIC
  45. "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  46. "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
  47. <hibernate-configuration>
  48. <session-factory>
  49. <property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
  50. <property name="connection.url">jdbc:oracle:thin:@127.0.0.1:1521:xe</property>
  51. <property name="connection.username">system</property>
  52. <property name="connection.password">admin</property>
  53. <property name="dialect">org.hibernate.dialect.OracleDialect</property>
  54.  
  55. <property name="show_sql">false</property>
  56. <property name="hibernate.hbm2ddl.auto">update</property><!-- create/update -->
  57. <!-- Mapping files -->
  58.  
  59. <mapping resource="employee.hbm.xml"/>
  60. </session-factory>
  61. </hibernate-configuration>
Add Comment
Please, Sign In to add comment