Package org.hibernate.cfg

Examples of org.hibernate.cfg.Configuration.buildSessionFactory()


   }
   public void sessionInit( )
      throws HibernateException
   {
      Configuration cfg = new Configuration().configure();
      SessionFactory sf = cfg.buildSessionFactory();
      System.out.println("Initialized session: "+sf);
   }

   public Person loadUser(long id) throws HibernateException
   {
View Full Code Here


      fis.close();
      configuration.addProperties(properties);
      log.debug("Full Hibernate Plugin's Session Factory property file \"/"+fileProperties+"\" configured");
    }
   
    SessionFactory sessionFactory = configuration.buildSessionFactory();
   
    Session testSession = sessionFactory.openSession();
    testSession.connection().getMetaData().getCatalogs();
    testSession.close();
    return sessionFactory;
View Full Code Here

          cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" )
      );
      cfg.addResource( getBaseForMappings() + "extendshbm/Person.hbm.xml" );
      cfg.addResource( getBaseForMappings() + "extendshbm/Employee.hbm.xml" );

      cfg.buildSessionFactory();

      assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" ) );
      assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Person" ) );
      assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Employee" ) );
View Full Code Here

          "cannot be in the configuration yet!",
          cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" )
      );
      cfg.addResource( getBaseForMappings() + "extendshbm/Employee.hbm.xml" );

      cfg.buildSessionFactory();

      fail( "Should not be able to build sessionfactory without a Person" );
    }
    catch ( HibernateException e ) {
View Full Code Here

    Configuration cfg = new Configuration();

    try {
      cfg.addResource( getBaseForMappings() + "extendshbm/allseparateinone.hbm.xml" );

      cfg.buildSessionFactory();

      assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" ) );
      assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Person" ) );
      assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Employee" ) );
View Full Code Here

   }
   public void sessionInit( )
      throws HibernateException
   {
      Configuration cfg = new Configuration().configure();
      SessionFactory sf = cfg.buildSessionFactory();
      System.out.println("Initialized session: "+sf);
   }

   public Person loadUser(long id) throws HibernateException
   {
View Full Code Here

    byte[] bytes = SerializationHelper.serialize( cfg );
    cfg = ( Configuration ) SerializationHelper.deserialize( bytes );

    // try to build SF
    SessionFactory factory = cfg.buildSessionFactory();
    factory.close();
  }

  @Entity
  public static class Serial {
View Full Code Here

  public void testPersisterClassProvider() throws Exception {
    Configuration cfg = new Configuration();
    cfg.addAnnotatedClass( Gate.class );
    //no exception as the GoofyPersisterClassProvider is not set
    SessionFactory sessionFactory = cfg.buildSessionFactory();
    sessionFactory.close();


    cfg = new Configuration();
    cfg.addAnnotatedClass( Gate.class );
View Full Code Here

    cfg = new Configuration();
    cfg.addAnnotatedClass( Gate.class );
    cfg.setPersisterClassProvider( new GoofyPersisterClassProvider() );
    try {
      sessionFactory = cfg.buildSessionFactory();
      sessionFactory.close();
    }
    catch ( MappingException e ) {
      assertEquals(
          "The entity persister should be overridden",
View Full Code Here

    cfg = new Configuration();
    cfg.addAnnotatedClass( Portal.class );
    cfg.addAnnotatedClass( Window.class );
    cfg.setPersisterClassProvider( new GoofyPersisterClassProvider() );
    try {
      sessionFactory = cfg.buildSessionFactory();
      sessionFactory.close();
    }
    catch ( MappingException e ) {
      assertEquals(
          "The collection persister should be overridden but not the entity persister",
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.