Package org.hibernate.cfg

Examples of org.hibernate.cfg.AnnotationConfiguration


      // success
    }
  }

  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


        tuplizer.getIdentifierGetter() instanceof DirectPropertyAccessor.DirectGetter
    );
  }

  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

        tuplizer.getIdentifierGetter() instanceof BasicPropertyAccessor.BasicGetter
    );
  }

  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

        tuplizer.getIdentifierGetter() instanceof BasicPropertyAccessor.BasicGetter
    );
  }

  public void testExplicitPropertyAccessAnnotationsOnField() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.addAnnotatedClass( Course4.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

      // success
    }
  }

  public void testExplicitPropertyAccessAnnotationsWithHibernateStyleOverride() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    Class<?> classUnderTest = Course3.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

        tuplizer.getGetter( 0 ) instanceof BasicPropertyAccessor.BasicGetter
    );
  }

  public void testExplicitPropertyAccessAnnotationsWithJpaStyleOverride() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    Class<?> classUnderTest = Course5.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

        tuplizer.getGetter( 0 ) instanceof BasicPropertyAccessor.BasicGetter
    );
  }

  public void testDefaultFieldAccessIsInherited() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    Class<?> classUnderTest = User.class;
    cfg.addAnnotatedClass( classUnderTest );
    cfg.addAnnotatedClass( Person.class );
    cfg.addAnnotatedClass( Being.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 since the default access mode gets inherited",
View Full Code Here

        tuplizer.getIdentifierGetter() instanceof DirectPropertyAccessor.DirectGetter
    );
  }

  public void testDefaultPropertyAccessIsInherited() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.addAnnotatedClass( Horse.class );
    cfg.addAnnotatedClass( Animal.class );

    SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
    EntityMetamodel metaModel = factory.getEntityPersister( Animal.class.getName() )
        .getEntityMetamodel();
    PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
    assertTrue(
        "Property access should be used since explicity configured via @Access",
View Full Code Here

  /**
   * HHH-5004
   */
  public void testAccessOnClassAndId() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.addAnnotatedClass( Course8.class );
    cfg.addAnnotatedClass( Student.class );
    cfg.buildSessionFactory();
  }
View Full Code Here

    assertNotNull( entityType );
  }

  @SuppressWarnings({ "unchecked" })
  public void testBuildingMetamodelWithParameterizedCollection() {
    AnnotationConfiguration cfg = new AnnotationConfiguration( );
    configure( cfg );
    cfg.addAnnotatedClass( WithGenericCollection.class );
    cfg.buildMappings();
    SessionFactoryImplementor sfi = (SessionFactoryImplementor) cfg.buildSessionFactory();
    MetamodelImpl.buildMetamodel( cfg.getClassMappings(), sfi );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.cfg.AnnotationConfiguration

Copyright © 2018 www.massapicom. 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.