Package org.hibernate.cfg

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


                    cfg.addAnnotatedClass(clazz);
                }
            }
        });

        final SessionFactory sessionFactory = cfg.buildSessionFactory();

        Provider<Session> sessionProvider = new Provider<Session>() {
            public Session get() {
                return sessionFactory.openSession();
            }
View Full Code Here


            }
        }

        long configurationComplete = System.currentTimeMillis();

        _sessionFactory = configuration.buildSessionFactory();

        long factoryCreated = System.currentTimeMillis();

        log.info(HibernateMessages.startupTiming(configurationComplete - startTime, factoryCreated
                - startTime));
View Full Code Here

  public void testTypeDefWithoutNameAndDefaultForTypeAttributes() {
   
    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(LocalContactDetails.class);
      config.buildSessionFactory();
      fail("Did not throw expected exception");
    }
    catch( AnnotationException ex ) {
      assertEquals(
          "Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass org.hibernate.test.annotations.entity.PhoneNumberType",
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

    }
    for ( String configFile : configFiles ) {
      InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( configFile );
      cfg.addInputStream( is );
    }
    return ( SessionFactoryImplementor ) cfg.buildSessionFactory();
  }

  // uses the first getter of the tupelizer for the assertions

  private void assertAccessType(SessionFactoryImplementor factory, Class<?> classUnderTest, AccessType accessType) {
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

    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.setNamingStrategy(new DummyNamingStrategy());
      config.addAnnotatedClass(Address.class);
      config.addAnnotatedClass(Person.class);
      config.buildSessionFactory();
    }
    catch( Exception e ) {
      StringWriter writer = new StringWriter();
      e.printStackTrace(new PrintWriter(writer));
      log.debug(writer.toString());
View Full Code Here

    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.setNamingStrategy(EJB3NamingStrategy.INSTANCE);
      config.addAnnotatedClass(A.class);
      config.addAnnotatedClass(AddressEntry.class);
      config.buildSessionFactory();
      Mappings mappings = config.createMappings();
      boolean foundIt = false;

      for ( Iterator iter = mappings.iterateTables(); iter.hasNext()) {
        Table table = (Table) iter.next();
View Full Code Here

  public void testWithoutCustomNamingStrategy() throws Exception {
    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(Address.class);
      config.addAnnotatedClass(Person.class);
      config.buildSessionFactory();
    }
    catch( Exception e ) {
      StringWriter writer = new StringWriter();
      e.printStackTrace(new PrintWriter(writer));
      log.debug(writer.toString());
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

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.