Package org.hibernate.cfg

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


        AnnotationConfiguration configuration = new AnnotationConfiguration();
        configuration.addAnnotatedClass( getUcl().loadClass( "org.hibernate.tool.hbm2x.Train" ) );
        configuration.addAnnotatedClass( getUcl().loadClass( "org.hibernate.tool.hbm2x.Passenger" ) );

        configuration.setProperty( "hibernate.hbm2ddl.auto", "create-drop" );
        SessionFactory sf = configuration.buildSessionFactory();
        Session s = sf.openSession();
                Query createQuery = s.createQuery("from java.lang.Object");
                createQuery.list();
        s.close();
        sf.close();
View Full Code Here


         AnnotationConfiguration configuration = new AnnotationConfiguration();
        Class puppet = getUcl().loadClass( "org.hibernate.tool.hbm2x." + className );
        configuration.addAnnotatedClass( puppet );
       
        configuration.setProperty( "hibernate.hbm2ddl.auto", "create-drop" );
        SessionFactory sf = configuration.buildSessionFactory();
        Session s = sf.openSession();

        Object puppetInst = puppet.newInstance();
        puppet.getMethod( "setName", new Class[]{String.class} ).invoke( puppetInst, new Object[]{"Barbie"} );
       
View Full Code Here

         AnnotationConfiguration configuration = new AnnotationConfiguration();
         configuration.addAnnotatedClass( getUcl().loadClass( "Vehicle" ) );
         configuration.addAnnotatedClass( getUcl().loadClass( "Person" ) );
         configuration.addAnnotatedClass( getUcl().loadClass( "Modelyear" ) );

         SessionFactory sf = configuration.buildSessionFactory();
         Session s = sf.openSession();
                 Query createQuery = s.createQuery("from java.lang.Object");
                 createQuery.list();
         s.close();
         sf.close();
View Full Code Here

    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(Bunny.class);
      config.addAnnotatedClass(PointyTooth.class);
      config.addAnnotatedClass(TwinkleToes.class);
      config.buildSessionFactory();
      String[] schema = config
          .generateSchemaCreationScript(new SQLServerDialect());
      for (String s : schema) {
        log.debug(s);
      }
View Full Code Here

    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.addAnnotatedClass( Show.class )
        .addAnnotatedClass( ShowDescription.class );
    cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
    try {
      SessionFactory sf = cfg.buildSessionFactory();
      fail( "Wrong mappedBy does not fail property" );
    }
    catch (AnnotationException e) {
      //success
    }
View Full Code Here

    p.put( "hibernate.show_sql", "true" );
    ac.setProperties( p );
    ac.addAnnotatedClass( Plane.class );
    SessionFactory sf;
    try {
      sf = ac.buildSessionFactory();
      fail( "Driver property overriding should work" );
      sf.close();
    }
    catch (HibernateException he) {
      //success
View Full Code Here

    try {
      cfg.addAnnotatedClass( Flight.class );
      cfg.addAnnotatedClass( org.hibernate.test.annotations.Flight.class );
      cfg.addResource( "org/hibernate/test/annotations/orm.xml");
      cfg.addResource( "org/hibernate/test/annotations/duplicatedgenerator/orm.xml");
      cfg.buildSessionFactory();
      fail( "Should not be able to map the same entity name twice" );
    }
    catch (AnnotationException ae) {
      //success
    }
View Full Code Here

    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(Bunny.class);
      config.addAnnotatedClass(PointyTooth.class);
      config.addAnnotatedClass(TwinkleToes.class);
      config.buildSessionFactory();
      String[] schema = config
          .generateSchemaCreationScript(new SQLServerDialect());
      for (String s : schema) {
        log.debug(s);
      }
View Full Code Here

 
  public void testMiscplacedImmutableAnnotation() {
    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(Foobar.class);
      config.buildSessionFactory();
      fail();
    } catch (AnnotationException ae) {
      log.debug("succes");
    }
  }
View Full Code Here

            //TODO: make it optional to add annotated classes here

            if (addMappedClasses != null && addMappedClasses.equals("false"))
            {
               return config.buildSessionFactory();
            }
            else
            {

               return config.addAnnotatedClass(HibernateIdentityObject.class)
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.