Examples of buildSessionFactory()


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

    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

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

    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

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

  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

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

    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

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

  public void testBackquotes() {
    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(Bug.class);
      config.addAnnotatedClass(Category.class);
      config.buildSessionFactory();
    }
    catch( Exception e ) {
      StringWriter writer = new StringWriter();
      e.printStackTrace(new PrintWriter(writer));
      log.debug(writer.toString());
View Full Code Here

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

  public void testInvalidReferenceToQuotedTableName() {
      try {
        AnnotationConfiguration config = new AnnotationConfiguration();
        config.addAnnotatedClass(Printer.class);
        config.addAnnotatedClass(PrinterCable.class);
        config.buildSessionFactory();
        fail("expected MappingException to be thrown");
      }
      //we WANT MappingException to be thrown
        catch( MappingException e ) {
          assertTrue("MappingException was thrown", true);
View Full Code Here

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

  public void testInconsistentAnnotationPlacement() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.addAnnotatedClass( Course1.class );
    cfg.addAnnotatedClass( Student.class );
    try {
      cfg.buildSessionFactory();
      fail( "@Id and @OneToMany are not placed consistently in test entities. SessionFactory creation should fail." );
    }
    catch ( MappingException e ) {
      // success
    }
View Full Code Here

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

  public void testFieldAnnotationPlacement() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    Class<?> classUnderTest = Course6.class;
    cfg.addAnnotatedClass( classUnderTest );
    cfg.addAnnotatedClass( Student.class );
    SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
    EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
        .getEntityMetamodel();
    PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
    assertTrue(
        "Field access should be used.",
View Full Code Here

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

  public void testPropertyAnnotationPlacement() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    Class<?> classUnderTest = Course7.class;
    cfg.addAnnotatedClass( classUnderTest );
    cfg.addAnnotatedClass( Student.class );
    SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
    EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
        .getEntityMetamodel();
    PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
    assertTrue(
        "Property access should be used.",
View Full Code Here

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

  public void testExplicitPropertyAccessAnnotationsOnProperty() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    Class<?> classUnderTest = Course2.class;
    cfg.addAnnotatedClass( classUnderTest );
    cfg.addAnnotatedClass( Student.class );
    SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
    EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
        .getEntityMetamodel();
    PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
    assertTrue(
        "Property access should be used.",
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.