Untitled
Anonymous
plain_text
11/08/2022 3:15 AM
1.5 KB
16
Indexable
public static org.hibernate.SessionFactory getSessionFactory() {
try {
if (sessionFactory == null) {
final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
.configure() // configures settings from hibernate.cfg.xml
.build();
sessionFactory = new MetadataSources(registry).addAnnotatedClass(StockAndInventory.class)
.addAnnotatedClass(Staff.class).addAnnotatedClass(Customer.class).addAnnotatedClass(Date.class)
.buildMetadata().buildSessionFactory();
JOptionPane.showMessageDialog(null, "DB Connection Establised",
"CONNECTION STATUS", JOptionPane.INFORMATION_MESSAGE);
return sessionFactory;
}
} catch (HibernateError ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(null, "Could not connection to database\n" + ex, "Connection Failure", JOptionPane.ERROR_MESSAGE);
}
return sessionFactory;
}Editor is loading...