@Override public Class getIdType() { if ( javaType == null ) { javaType = buildingContext .getBootstrapContext() .getReflectionManager() .toClass( javaTypeXClass ); } return javaType; }
@Override public Class getIdType() { return buildingContext .getBootstrapContext() .getReflectionManager() .toClass( idXProperty.getType() ); }
public static MappedSuperclass getMappedSuperclassOrNull( XClass declaringClass, Map<XClass, InheritanceState> inheritanceStatePerClass, MetadataBuildingContext context) { boolean retrieve = false; if ( declaringClass != null ) { final InheritanceState inheritanceState = inheritanceStatePerClass.get( declaringClass ); if ( inheritanceState == null ) { throw new org.hibernate.annotations.common.AssertionFailure( "Declaring class is not found in the inheritance state hierarchy: " + declaringClass ); } if ( inheritanceState.isEmbeddableSuperclass() ) { retrieve = true; } } if ( retrieve ) { return context.getMetadataCollector().getMappedSuperclass( context.getBootstrapContext().getReflectionManager().toClass( declaringClass ) ); } else { return null; } }
@Override public void buildCallbacksForEmbeddable( Property embeddableProperty, String entityClassName, CallbackRegistrar callbackRegistrar) { try { final XClass entityXClass = reflectionManager.classForName( entityClassName ); final Class entityClass = reflectionManager.toClass( entityXClass ); for ( CallbackType callbackType : CallbackType.values() ) { final Callback[] callbacks = resolveEmbeddableCallbacks( entityClass, embeddableProperty, callbackType, reflectionManager ); callbackRegistrar.registerCallbacks( entityClass, callbacks ); } } catch (ClassLoadingException e) { throw new MappingException( "Class not found: ", e ); } }
private void addPropertyToMappedSuperclass(Property prop, XClass declaringClass) { final Class type = getContext().getBootstrapContext().getReflectionManager().toClass( declaringClass ); MappedSuperclass superclass = getContext().getMetadataCollector().getMappedSuperclass( type ); superclass.addDeclaredProperty( prop ); }
valueGeneration.initialize( annotation, buildingContext.getBootstrapContext().getReflectionManager().toClass( property.getType() ) );
reflectionManager.toClass( xProperty.getDeclaringClass() ) ); final ResolvedTypeWithMembers declaringClassWithMembers = classmateContext.getMemberResolver().resolve(
@Override public void buildCallbacksForEntity(String entityClassName, CallbackRegistrar callbackRegistrar) { final boolean debugEnabled = log.isDebugEnabled(); try { final XClass entityXClass = reflectionManager.classForName( entityClassName ); final Class entityClass = reflectionManager.toClass( entityXClass ); for ( CallbackType callbackType : CallbackType.values() ) { if ( callbackRegistrar.hasRegisteredCallbacks( entityClass, callbackType ) ) { // this most likely means we have a class mapped multiple times using the hbm.xml // "entity name" feature if ( debugEnabled ) { log.debugf( "CallbackRegistry reported that Class [%s] already had %s callbacks registered; " + "assuming this means the class was mapped twice " + "(using hbm.xml entity-name support) - skipping subsequent registrations", entityClassName, callbackType.getCallbackAnnotation().getSimpleName() ); } continue; } final Callback[] callbacks = resolveEntityCallbacks( entityXClass, callbackType, reflectionManager ); callbackRegistrar.registerCallbacks( entityClass, callbacks ); } } catch (ClassLoadingException e) { throw new MappingException( "entity class not found: " + entityClassName, e ); } }
private void addMappedSuperClassInMetadata(PersistentClass persistentClass) { //add @MappedSuperclass in the metadata // classes from 0 to n-1 are @MappedSuperclass and should be linked org.hibernate.mapping.MappedSuperclass mappedSuperclass = null; final InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity( clazz, inheritanceStatePerClass ); PersistentClass superEntity = superEntityState != null ? buildingContext.getMetadataCollector().getEntityBinding( superEntityState.getClazz().getName() ) : null; final int lastMappedSuperclass = classesToProcessForMappedSuperclass.size() - 1; for ( int index = 0; index < lastMappedSuperclass; index++ ) { org.hibernate.mapping.MappedSuperclass parentSuperclass = mappedSuperclass; final Class<?> type = buildingContext.getBootstrapContext().getReflectionManager() .toClass( classesToProcessForMappedSuperclass.get( index ) ); //add MAppedSuperclass if not already there mappedSuperclass = buildingContext.getMetadataCollector().getMappedSuperclass( type ); if ( mappedSuperclass == null ) { mappedSuperclass = new org.hibernate.mapping.MappedSuperclass( parentSuperclass, superEntity ); mappedSuperclass.setMappedClass( type ); buildingContext.getMetadataCollector().addMappedSuperclass( type, mappedSuperclass ); } } if ( mappedSuperclass != null ) { persistentClass.setSuperMappedSuperclass( mappedSuperclass ); } }
private Class determineElementClass(XClass elementXClass) { if ( elementXClass != null ) { try { return getContext().getBootstrapContext().getReflectionManager().toClass( elementXClass ); } catch (Exception e) { log.debugf( "Unable to resolve XClass [%s] to Class for collection elements [%s]", elementXClass.getName(), collection.getRole() ); } } if ( collection.getElement() != null ) { if ( collection.getElement().getType() != null ) { return collection.getElement().getType().getReturnedClass(); } } // currently this is called from paths where the element type really should be known, // so log the fact that we could not resolve the collection element info log.debugf( "Unable to resolve element information for collection [%s]", collection.getRole() ); return null; }
private Class determineKeyClass(XClass keyXClass) { if ( keyXClass != null ) { try { return getContext().getBootstrapContext().getReflectionManager().toClass( keyXClass ); } catch (Exception e) { log.debugf( "Unable to resolve XClass [%s] to Class for collection key [%s]", keyXClass.getName(), collection.getRole() ); } } final IndexedCollection indexedCollection = (IndexedCollection) collection; if ( indexedCollection.getIndex() != null ) { if ( indexedCollection.getIndex().getType() != null ) { return indexedCollection.getIndex().getType().getReturnedClass(); } } // currently this is called from paths where the element type really should be known, // so log the fact that we could not resolve the collection element info log.debugf( "Unable to resolve key information for collection [%s]", collection.getRole() ); return null; } }
final Class attributeJavaType = buildingContext.getBootstrapContext().getReflectionManager().toClass( returnedClassOrElement ); if ( !Enum.class.isAssignableFrom( attributeJavaType ) ) { throw new AnnotationException(
public static MappedSuperclass getMappedSuperclassOrNull(XClass declaringClass, Map<XClass, InheritanceState> inheritanceStatePerClass, ExtendedMappings mappings) { boolean retrieve = false; if ( declaringClass != null ) { final InheritanceState inheritanceState = inheritanceStatePerClass.get( declaringClass ); if ( inheritanceState == null ) { throw new org.hibernate.annotations.common.AssertionFailure( "Declaring class is not found in the inheritance state hierarchy: " + declaringClass ); } if ( inheritanceState.isEmbeddableSuperclass() ) { retrieve = true; } } return retrieve ? mappings.getMappedSuperclass( mappings.getReflectionManager().toClass( declaringClass ) ) : null; }
private void addPropertyToMappedSuperclass(Property prop, XClass declaringClass) { final ExtendedMappings mappings = getMappings(); final Class type = mappings.getReflectionManager().toClass( declaringClass ); MappedSuperclass superclass = mappings.getMappedSuperclass( type ); superclass.addDeclaredProperty( prop ); }
private void addMappedSuperClassInMetadata(PersistentClass persistentClass) { //add @MappedSuperclass in the metadata // classes from 0 to n-1 are @MappedSuperclass and should be linked org.hibernate.mapping.MappedSuperclass mappedSuperclass = null; final InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity( clazz, inheritanceStatePerClass ); PersistentClass superEntity = superEntityState != null ? mappings.getClass( superEntityState.getClazz().getName() ) : null; final int lastMappedSuperclass = classesToProcessForMappedSuperclass.size() - 1; for ( int index = 0 ; index < lastMappedSuperclass ; index++ ) { org.hibernate.mapping.MappedSuperclass parentSuperclass = mappedSuperclass; final Class<?> type = mappings.getReflectionManager().toClass( classesToProcessForMappedSuperclass.get( index ) ); //add MAppedSuperclass if not already there mappedSuperclass = mappings.getMappedSuperclass( type ); if (mappedSuperclass == null) { mappedSuperclass = new org.hibernate.mapping.MappedSuperclass(parentSuperclass, superEntity ); mappedSuperclass.setMappedClass( type ); mappings.addMappedSuperclass( type, mappedSuperclass ); } } if (mappedSuperclass != null) { persistentClass.setSuperMappedSuperclass(mappedSuperclass); } }
private void writeObject(java.io.ObjectOutputStream out) throws IOException { out.defaultWriteObject(); List<Class> serializableAnnotatedClasses = new ArrayList<Class>( annotatedClasses.size() ); for ( XClass xClass : annotatedClasses ) { serializableAnnotatedClasses.add( reflectionManager.toClass( xClass ) ); } out.writeObject( serializableAnnotatedClasses ); }
private void addCallback( XClass entity, HashMap<Class, Callback[]> map, Class annotation, ReflectionManager reflectionManager ) { Callback[] callbacks = null; callbacks = CallbackResolver.resolveCallback( entity, annotation, reflectionManager ); map.put( reflectionManager.toClass( entity ), callbacks ); }
private static Class resolveJavaType(XClass returnedClassOrElement, MetadataBuildingContext buildingContext) { return buildingContext.getBootstrapContext() .getReflectionManager() .toClass( returnedClassOrElement ); }
@Override public Class getIdType() { return buildingContext .getBootstrapContext() .getReflectionManager() .toClass( idXProperty.getType() ); }
private void addPropertyToMappedSuperclass(Property prop, XClass declaringClass) { final Mappings mappings = getMappings(); final Class type = mappings.getReflectionManager().toClass( declaringClass ); MappedSuperclass superclass = mappings.getMappedSuperclass( type ); superclass.addDeclaredProperty( prop ); }