Package org.hibernate.cfg.annotations.reflection

Examples of org.hibernate.cfg.annotations.reflection.XMLContext


  }

  protected JPAOverridenAnnotationReader getReader(Class<?> entityClass, String fieldName, String ormResourceName)
      throws Exception {
    AnnotatedElement el = getAnnotatedElement( entityClass, fieldName );
    XMLContext xmlContext = getContext( ormResourceName );
    JPAOverridenAnnotationReader reader = new JPAOverridenAnnotationReader( el, xmlContext );
    return reader;
  }
View Full Code Here


    assertNotNull( "Could not load resource " + resourceName, is );
    return getContext( is );
  }

  protected XMLContext getContext(InputStream is) throws Exception {
    XMLContext xmlContext = new XMLContext();
    Document doc = new SAXReader().read( is );
    xmlContext.addDocument( doc );
    return xmlContext;
  }
View Full Code Here

  protected Class<?>[] getAnnotatedClasses() {
    return new Class<?>[0];
  }

  public void testMappedSuperclassAnnotations() throws Exception {
    XMLContext context = buildContext(
        "org/hibernate/test/annotations/reflection/metadata-complete.xml"
    );
    JPAOverridenAnnotationReader reader = new JPAOverridenAnnotationReader( Organization.class, context );
    assertTrue( reader.isAnnotationPresent( MappedSuperclass.class ) );
  }
View Full Code Here

    JPAOverridenAnnotationReader reader = new JPAOverridenAnnotationReader( Organization.class, context );
    assertTrue( reader.isAnnotationPresent( MappedSuperclass.class ) );
  }

  public void testEntityRelatedAnnotations() throws Exception {
    XMLContext context = buildContext( "org/hibernate/test/annotations/reflection/orm.xml" );
    JPAOverridenAnnotationReader reader = new JPAOverridenAnnotationReader( Administration.class, context );
    assertNotNull( reader.getAnnotation( Entity.class ) );
    assertEquals(
        "Default value in xml entity should not override @Entity.name", "JavaAdministration",
        reader.getAnnotation( Entity.class ).name()
View Full Code Here

        "discriminator-column.length broken", 34, reader.getAnnotation( DiscriminatorColumn.class ).length()
    );
  }

  public void testEntityRelatedAnnotationsMetadataComplete() throws Exception {
    XMLContext context = buildContext(
        "org/hibernate/test/annotations/reflection/metadata-complete.xml"
    );
    JPAOverridenAnnotationReader reader = new JPAOverridenAnnotationReader( Administration.class, context );
    assertNotNull( reader.getAnnotation( Entity.class ) );
    assertEquals(
View Full Code Here

    assertNull( reader.getAnnotation( SequenceGenerator.class ) );
    assertNull( reader.getAnnotation( TableGenerator.class ) );
  }

  public void testIdRelatedAnnotations() throws Exception {
    XMLContext context = buildContext( "org/hibernate/test/annotations/reflection/orm.xml" );
    Method method = Administration.class.getDeclaredMethod( "getId" );
    JPAOverridenAnnotationReader reader = new JPAOverridenAnnotationReader( method, context );
    assertNull( reader.getAnnotation( Id.class ) );
    assertNull( reader.getAnnotation( Column.class ) );
    Field field = Administration.class.getDeclaredField( "id" );
View Full Code Here

    assertNotNull( reader.getAnnotation( AttributeOverrides.class ) );
    assertEquals( 1, reader.getAnnotation( AttributeOverrides.class ).value().length );
  }

  public void testBasicRelatedAnnotations() throws Exception {
    XMLContext context = buildContext(
        "org/hibernate/test/annotations/reflection/metadata-complete.xml"
    );
    Field field = BusTrip.class.getDeclaredField( "status" );
    JPAOverridenAnnotationReader reader = new JPAOverridenAnnotationReader( field, context );
    assertNotNull( reader.getAnnotation( Enumerated.class ) );
View Full Code Here

    reader = new JPAOverridenAnnotationReader( field, context );
    assertNotNull( reader.isAnnotationPresent( Basic.class ) );
  }

  public void testVersionRelatedAnnotations() throws Exception {
    XMLContext context = buildContext( "org/hibernate/test/annotations/reflection/orm.xml" );
    Method method = Administration.class.getDeclaredMethod( "getVersion" );
    JPAOverridenAnnotationReader reader = new JPAOverridenAnnotationReader( method, context );
    assertNotNull( reader.getAnnotation( Version.class ) );

    Field field = Match.class.getDeclaredField( "version" );
View Full Code Here

    reader = new JPAOverridenAnnotationReader( field, context );
    assertNotNull( reader.getAnnotation( Version.class ) );
  }

  public void testTransientAndEmbeddedRelatedAnnotations() throws Exception {
    XMLContext context = buildContext( "org/hibernate/test/annotations/reflection/orm.xml" );

    Field field = Administration.class.getDeclaredField( "transientField" );
    JPAOverridenAnnotationReader reader = new JPAOverridenAnnotationReader( field, context );
    assertNotNull( reader.getAnnotation( Transient.class ) );
    assertNull( reader.getAnnotation( Basic.class ) );
View Full Code Here

    reader = new JPAOverridenAnnotationReader( field, context );
    assertNotNull( reader.getAnnotation( Embedded.class ) );
  }

  public void testAssociationRelatedAnnotations() throws Exception {
    XMLContext context = buildContext( "org/hibernate/test/annotations/reflection/orm.xml" );

    Field field = Administration.class.getDeclaredField( "defaultBusTrip" );
    JPAOverridenAnnotationReader reader = new JPAOverridenAnnotationReader( field, context );
    assertNotNull( reader.getAnnotation( OneToOne.class ) );
    assertNull( reader.getAnnotation( JoinColumns.class ) );
View Full Code Here

TOP

Related Classes of org.hibernate.cfg.annotations.reflection.XMLContext

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.