Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. <!DOCTYPE hibernate-configuration PUBLIC
  2. "=//Hibernate/Hibernate Configuration DTD 3.0//EN"
  3. "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
  4. <hibernate-configuration>
  5. <session-factory>
  6.  
  7. <!-- Database Dialect & Driver for Oracle 9G-->
  8. <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
  9. <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
  10.  
  11. <!-- Database Details-->
  12. <property name="connection.username">root</property>
  13. <property name="connection.password">1997</property>
  14. <property name="connection.url">jdbc:mysql:192.168.0.0/CCIBD</property>
  15.  
  16. <property name="connection.pool_size">1</property>
  17. <property name="hibernate.default_schema">root</property>
  18.  
  19. <!-- Additional Properties -->
  20. <property name="show_sql">true</property>
  21.  
  22. <property name="hbm2ddl.auto">update</property>
  23.  
  24. <!-- Table Mapping -->
  25. <mapping resource="hibernate.hbm.xml"/>
  26.  
  27. </session-factory>
  28. </hibernate-configuration>
  29.  
  30. <?xml version="1.0"?>
  31. <!DOCTYPE hibernate-mapping PUBLIC
  32. "-//Hibernate-mapping Mapping DTD 3.0//EN"
  33. "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  34.  
  35. <hibernate-mapping>
  36.  
  37. <class name="HibUsuario" table="Usuario">
  38. <meta attribute="class-description">
  39. This class contains the USUARIO mapping.
  40. </meta>
  41.  
  42. <id name="cpf" type="int" column="cpf">
  43. <generator class="native"/>
  44. </id>
  45.  
  46. <property name="usuario" type="string" column="usuario" not-null="true"/>
  47. <property name="senha" type="string" column="senha" not-null="true"/>
  48. <property name="permissao" type="string" column="permissao" not-null="true"/>
  49.  
  50. </class>
  51.  
  52. </hibernate-mapping>
  53.  
  54. package Factory;
  55.  
  56.  
  57. import org.hibernate.SessionFactory;
  58. import org.hibernate.cfg.Configuration;
  59.  
  60. public class HibernateUtil {
  61.  
  62. private static final SessionFactory sessionFactory;
  63.  
  64. static {
  65. try {
  66. sessionFactory = new Configuration().configure().buildSessionFactory();
  67. }
  68. catch (Throwable ex){
  69. System.err.println("Initial SessionFactory creation failed." + ex);
  70. throw new ExceptionInInitializerError(ex);
  71. }
  72. }
  73.  
  74. public static SessionFactory getSessionFactory(){
  75. return sessionFactory;
  76. }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement