Advertisement
Guest User

Untitled

a guest
Jul 6th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <hibernate-configuration>
  2.  
  3. <session-factory>
  4.  
  5. <!-- Database connection settings -->
  6. <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
  7. <property name="connection.url">jdbc:mysql://localhost:3306/Drogaria</property>
  8. <property name="connection.username">root</property>
  9. <property name="connection.password">ricardo</property>
  10.  
  11.  
  12. <!-- SQL dialect -->
  13. <property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
  14.  
  15.  
  16. <!-- Enable Hibernate's automatic session context management -->
  17. <property name="current_session_context_class">thread</property>
  18.  
  19. <!-- Disable the second-level cache -->
  20. <property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
  21.  
  22. <!-- Echo all executed SQL to stdout -->
  23. <property name="show_sql">true</property>
  24.  
  25. <!-- Drop and re-create the database schema on startup -->
  26. <property name="hibernate.hbm2ddl.auto">update</property>
  27.  
  28. <mapping class="br.com.drogaria.domain.Fabricante"/>
  29. </session-factory>
  30.  
  31. private static final SessionFactory sessionFactory = buildSessionFactory();
  32.  
  33. private static SessionFactory buildSessionFactory() {
  34.  
  35.  
  36. try {
  37. Configuration configuration = new Configuration().configure("hibernate.cfg.xml");
  38. return configuration.buildSessionFactory( new StandardServiceRegistryBuilder().applySettings( configuration.getProperties() ).build() );
  39. }
  40. catch (Throwable ex) {
  41. throw new ExceptionInInitializerError(ex);
  42. }
  43. }
  44.  
  45. public static SessionFactory getSessionFactory() {
  46. return sessionFactory;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement