Package org.hibernate.reflection

Examples of org.hibernate.reflection.XClass


  @SuppressWarnings("unchecked")
  private void createChildValidator( XMember member) {
    if ( member.isAnnotationPresent( Valid.class ) ) {
      setAccessible( member );
      childGetters.add( member );
      XClass clazz;
      if ( member.isCollection() || member.isArray() ) {
        clazz = member.getElementClass();
      }
      else {
        clazz = member.getType();
View Full Code Here


  XClass grandpa = factory.toXClass( Grandpa.class );

  public void testHasAPointOfViewClass() {
    // Since Dad is an Entity, getting it through Son.getSuperclass() gives
    // us a view of properties from Dad with Son as a point of view.
    XClass sameView = factory.toXClass( Son.class ).getSuperclass();
    XClass differentView = factory.toXClass( Dad.class );
    assertSame( "Should be the same instance: same owner", sameView, fatherAsSeenFromSon );
    assertNotSame( "Should be a different instance: different owner", differentView, fatherAsSeenFromSon );
    assertEquals( ".equals() should show equality", sameView, differentView );
  }
View Full Code Here

    assertEquals( "methodProperty", getConcreteInstance().getName() );
  }

  @Override
  protected XProperty getConcreteInstance() {
    XClass xClass = factory.toXClass( Dad.class );
    List<XProperty> properties = xClass.getDeclaredProperties( "property" );
    for ( XProperty p : properties ) {
      if ( p.getName().equals( "methodProperty" ) ) {
        return p;
      }
    }
View Full Code Here

public class JavaReflectionManagerTest extends TestCase {

  private ReflectionManager rm = new JavaXFactory();

  public void testReturnsAnXClassThatWrapsTheGivenClass() {
    XClass xc = rm.toXClass( Integer.class );
    assertEquals( "java.lang.Integer", xc.getName() );
  }
View Full Code Here

    XClass xc = rm.toXClass( Integer.class );
    assertEquals( "java.lang.Integer", xc.getName() );
  }

  public void testReturnsSameXClassForSameClass() {
    XClass xc1 = rm.toXClass( void.class );
    XClass xc2 = rm.toXClass( void.class );
    assertSame( xc2, xc1 );
  }
View Full Code Here

  public void testReturnsNullForANullClass() {
    assertNull( rm.toXClass( null ) );
  }

  public void testComparesXClassesWithClasses() {
    XClass xc = rm.toXClass( Integer.class );
    assertTrue( rm.equals( xc, Integer.class ) );
  }
View Full Code Here

    XClass xc = rm.toXClass( Integer.class );
    assertTrue( rm.equals( xc, Integer.class ) );
  }

  public void testSupportsNullsInComparisons() {
    XClass xc = rm.toXClass( Integer.class );
    assertFalse( rm.equals( null, Number.class ) );
    assertFalse( rm.equals( xc, null ) );
    assertTrue( rm.equals( null, null ) );
  }
View Full Code Here

    //process idclass if any
    Set<String> idProperties = new HashSet<String>();
    IdClass idClass = null;
    if ( ! inheritanceState.hasParents ) {
      //look for idClass
      XClass current = inheritanceState.clazz;
      InheritanceState state = inheritanceState;
      do {
        current = state.clazz;
        if ( current.isAnnotationPresent( IdClass.class ) ) {
          idClass = current.getAnnotation( IdClass.class );
          break;
        }
        state = InheritanceState.getSuperclassInheritanceState(
            current, inheritanceStatePerClass, mappings.getReflectionManager()
        );
      }
      while ( state != null );
    }
    if ( idClass != null ) {
      XClass compositeClass = mappings.getReflectionManager().toXClass( idClass.value() );
      boolean isComponent = true;
      boolean propertyAnnotated = entityBinder.isPropertyAnnotated( compositeClass );
      String propertyAccessor = entityBinder.getPropertyAccessor( compositeClass );
      String generatorType = "assigned";
      String generator = BinderHelper.ANNOTATION_STRING_DEFAULT;
View Full Code Here

        Boolean.TRUE :  //default to property and fallback if needed
        isExplicitPropertyAnnotated;
    String accessType = explicitAccessType != null ? explicitAccessType : "property";

    for ( int index = 0; index < deep ; index++ ) {
      XClass clazz = classesToProcess.get( index );
     
      boolean currentHasIdentifier = addElementsOfAClass(
          elements, propertyHolder, isPropertyAnnotated,
          accessType, clazz, mappings
      );
      hasIdentifier = hasIdentifier || currentHasIdentifier;
    }

    if ( !hasIdentifier && !inheritanceState.hasParents ) {
      if ( isExplicitPropertyAnnotated != null ) return null; //explicit but no @Id
      isPropertyAnnotated = !isPropertyAnnotated;
      accessType = "field";
      elements.clear();
      for ( int index = 0; index < deep ; index++ ) {
        XClass clazz = classesToProcess.get( index );
        boolean currentHasIdentifier = addElementsOfAClass(
            elements, propertyHolder, isPropertyAnnotated,
            accessType, clazz, mappings
        );
        hasIdentifier = hasIdentifier || currentHasIdentifier;
View Full Code Here

      XClass annotatedClass, Map<XClass, InheritanceState> inheritanceStatePerClass,
      InheritanceState inheritanceState, ExtendedMappings mappings
  ) {
    //ordered to allow proper messages on properties subclassing
    List<XClass> classesToProcess = new ArrayList<XClass>();
    XClass currentClassInHierarchy = annotatedClass;
    InheritanceState superclassState;
    do {
      classesToProcess.add( 0, currentClassInHierarchy );
      XClass superClass = currentClassInHierarchy;
      do {
        superClass = superClass.getSuperclass();
        superclassState = inheritanceStatePerClass.get( superClass );
      }
      while ( !mappings.getReflectionManager().equals( superClass, Object.class ) && superclassState == null );

      currentClassInHierarchy = superClass;
View Full Code Here

TOP

Related Classes of org.hibernate.reflection.XClass

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.