Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. public class App
  2. {
  3.     public static void main( String[] args )
  4.     {
  5.         Configuration configuration = new Configuration().configure();
  6.    
  7.         SessionFactory sessionFactory = configuration.buildSessionFactory(
  8.                 new ServiceRegistryBuilder().applySettings(
  9.                         configuration.getProperties()).buildServiceRegistry());
  10.        
  11.         Session session = sessionFactory.openSession();
  12.         session.beginTransaction();
  13.        
  14.         EventClass exceptionClass = new EventClass( "Exception" , 0);
  15.         EventClass triggerClass = new EventClass( "Trigger" , 1);
  16.        
  17.         session.save( exceptionClass );
  18.         session.save( triggerClass );
  19.        
  20.         session.save( new Event( "Our very first event!", triggerClass) );
  21.         session.save( new Event( "Our very second event!", exceptionClass) );
  22.         session.save( new Event( "Our very third event!", exceptionClass) );
  23.         session.getTransaction().commit();
  24.         session.close();
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement