Package org.hibernate.cfg

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


  public void testHbmWithSubclassExtends() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
    cfg.addClass( Ferry.class );
    cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
    SessionFactory sf = cfg.buildSessionFactory();
    assertNotNull( sf );
    Session s = sf.openSession();
    Transaction tx = s.beginTransaction();
    Query q = s.createQuery( "from Ferry" );
    assertEquals( 0, q.list().size() );
View Full Code Here


  public void testAnnReferencesHbm() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
    cfg.addAnnotatedClass( Port.class );
    cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
    SessionFactory sf = cfg.buildSessionFactory();
    assertNotNull( sf );
    Session s = sf.openSession();
    Transaction tx = s.beginTransaction();
    Query q = s.createQuery( "from Boat" );
    assertEquals( 0, q.list().size() );
View Full Code Here

  public void testDeclarativeMix() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.addAnnotatedClass( IncorrectEntity.class );
    cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
    try {
      SessionFactory sf = cfg.buildSessionFactory();
      fail( "Entity wo id should fail" );
    }
    catch (AnnotationException e) {
      //success
    }
View Full Code Here

      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(A.class);
      config.addAnnotatedClass(B.class);
      config.addAnnotatedClass(C.class);
      config.addAnnotatedClass(D.class);
      config.buildSessionFactory();
      String[] schema = config
          .generateSchemaCreationScript(new SQLServerDialect());
      for (String s : schema) {
        log.debug(s);
      }
View Full Code Here

      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(ClassA.class);
      config.addAnnotatedClass(ClassB.class);
      config.addAnnotatedClass(ClassC.class);
      config.addAnnotatedClass(ClassD.class);
      config.buildSessionFactory();
      String[] schema = config
          .generateSchemaCreationScript(new HSQLDialect());
      for (String s : schema) {
        log.debug(s);
      }
View Full Code Here

    AnnotationConfiguration config = new AnnotationConfiguration();
    config.addAnnotatedClass( Customer.class );
    config.addAnnotatedClass( Order.class );
    config.addAnnotatedClass( SupportTickets.class );
    config.addAnnotatedClass( Country.class );
    SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory();

    assertTrue(
        "fetch profile not parsed properly",
        sessionImpl.containsFetchProfileDefinition( "customer-with-orders" )
    );
View Full Code Here

    config.addAnnotatedClass( Customer2.class );
    config.addAnnotatedClass( Order.class );
    config.addAnnotatedClass( Country.class );

    try {
      config.buildSessionFactory();
      fail();
    }
    catch ( MappingException e ) {
      log.trace( "success" );
    }
View Full Code Here

    config.addAnnotatedClass( Customer3.class );
    config.addAnnotatedClass( Order.class );
    config.addAnnotatedClass( Country.class );

    try {
      config.buildSessionFactory();
      fail();
    }
    catch ( MappingException e ) {
      log.trace( "success" );
    }
View Full Code Here

    config.addAnnotatedClass( Customer4.class );
    config.addAnnotatedClass( Order.class );
    config.addAnnotatedClass( Country.class );

    try {
      config.buildSessionFactory();
      fail();
    }
    catch ( MappingException e ) {
      log.trace( "success" );
    }
View Full Code Here

    config.addAnnotatedClass( Country.class );
    InputStream is = Thread.currentThread()
        .getContextClassLoader()
        .getResourceAsStream( "org/hibernate/test/annotations/fetchprofile/mappings.hbm.xml" );
    config.addInputStream( is );
    SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory();

    assertTrue(
        "fetch profile not parsed properly",
        sessionImpl.containsFetchProfileDefinition( "orders-profile" )
    );
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.