public DynamicComponentSource(ReflectionManager reflectionManager, Component component, XProperty baseProperty) { super( reflectionManager.toXClass( Map.class ), component ); this.baseProperty = baseProperty; } }
@Override public Class getIdType() { if ( javaType == null ) { javaType = buildingContext .getBootstrapContext() .getReflectionManager() .toClass( javaTypeXClass ); } return javaType; }
if ( buildingContext.getBootstrapContext().getReflectionManager().equals( returnedClassOrElement, Date.class ) ) { isDate = true; else if ( buildingContext.getBootstrapContext().getReflectionManager().equals( returnedClassOrElement, Calendar.class ) ) { isDate = false; if ( buildingContext.getBootstrapContext().getReflectionManager().equals( returnedClassOrElement, java.sql.Clob.class ) ) { type = isNationalized ? StandardBasicTypes.NCLOB.getName() : StandardBasicTypes.CLOB.getName(); else if ( buildingContext.getBootstrapContext().getReflectionManager().equals( returnedClassOrElement, java.sql.NClob.class ) ) { type = StandardBasicTypes.NCLOB.getName(); else if ( buildingContext.getBootstrapContext().getReflectionManager().equals( returnedClassOrElement, java.sql.Blob.class ) ) { type = "blob"; else if ( buildingContext.getBootstrapContext().getReflectionManager().equals( returnedClassOrElement, String.class ) ) { type = isNationalized ? StandardBasicTypes.MATERIALIZED_NCLOB.getName() : StandardBasicTypes.MATERIALIZED_CLOB.getName(); else if ( buildingContext.getBootstrapContext().getReflectionManager().equals( returnedClassOrElement, Character.class ) && isArray ) { type = isNationalized ? CharacterArrayNClobType.class.getName() : CharacterArrayClobType.class.getName(); else if ( buildingContext.getBootstrapContext().getReflectionManager().equals( returnedClassOrElement, char.class ) && isArray ) { type = isNationalized
@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 ); } }
final XClass embeddableXClass = reflectionManager.classForName( embeddableClassName ); final Getter embeddableGetter = embeddableProperty.getGetter( entityClass ); final boolean debugEnabled = log.isDebugEnabled(); for ( final XMethod xMethod : methods ) { if ( xMethod.isAnnotationPresent( callbackType.getCallbackAnnotation() ) ) { Method method = reflectionManager.toMethod( xMethod ); final String methodName = method.getName(); if ( !callbacksMethodNames.contains( methodName ) ) {
for ( final XMethod xMethod : methods ) { if ( xMethod.isAnnotationPresent( callbackType.getCallbackAnnotation() ) ) { Method method = reflectionManager.toMethod( xMethod ); final String methodName = method.getName(); if ( !callbacksMethodNames.contains( methodName ) ) { List<Class> defaultListeners = (List<Class>) reflectionManager.getDefaults().get( EntityListeners.class ); Callback callback = null; if ( listener != null ) { XClass xListener = reflectionManager.toXClass( listener ); callbacksMethodNames = new ArrayList<>(); List<XMethod> methods = xListener.getDeclaredMethods(); for ( final XMethod xMethod : methods ) { if ( xMethod.isAnnotationPresent( callbackType.getCallbackAnnotation() ) ) { final Method method = reflectionManager.toMethod( xMethod ); final String methodName = method.getName(); if ( !callbacksMethodNames.contains( methodName ) ) {
private void orderHierarchy(List<XClass> copy, List<XClass> newList, List<XClass> original, XClass clazz) { if ( clazz == null || reflectionManager.equals( clazz, Object.class ) ) { return; } //process superclass first orderHierarchy( copy, newList, original, clazz.getSuperclass() ); if ( original.contains( clazz ) ) { if ( !newList.contains( clazz ) ) { newList.add( clazz ); } copy.remove( clazz ); } }
public static void bindDefaults(MetadataBuildingContext context) { Map defaults = context.getBootstrapContext().getReflectionManager().getDefaults();
if ( mappings.getReflectionManager().equals( returnedClassOrElement, Date.class ) ) { isDate = true; else if ( mappings.getReflectionManager().equals( returnedClassOrElement, Calendar.class ) ) { isDate = false; if ( mappings.getReflectionManager().equals( returnedClassOrElement, java.sql.Clob.class ) ) { type = "clob"; else if ( mappings.getReflectionManager().equals( returnedClassOrElement, java.sql.Blob.class ) ) { type = "blob"; else if ( mappings.getReflectionManager().equals( returnedClassOrElement, String.class ) ) { type = Hibernate.MATERIALIZED_CLOB.getName(); else if ( mappings.getReflectionManager().equals( returnedClassOrElement, Character.class ) && isArray ) { type = CharacterArrayClobType.class.getName(); else if ( mappings.getReflectionManager().equals( returnedClassOrElement, char.class ) && isArray ) { type = PrimitiveCharacterArrayClobType.class.getName(); else if ( mappings.getReflectionManager().equals( returnedClassOrElement, Byte.class ) && isArray ) { type = WrappedMaterializedBlobType.class.getName(); else if ( mappings.getReflectionManager().equals( returnedClassOrElement, byte.class ) && isArray ) { type = Hibernate.MATERIALIZED_BLOB.getName(); .toXClass( Serializable.class ) .isAssignableFrom( returnedClassOrElement ) ) {
@SuppressWarnings("deprecation") private XClass toXClass(String className, ReflectionManager reflectionManager) { try { return reflectionManager.classForName( className ); } catch ( ClassLoadingException e ) { throw new AnnotationException( "Unable to load class defined in XML: " + className, e ); } }
@SuppressWarnings({"unchecked", "WeakerAccess"}) public Callback[] resolveEmbeddableCallbacks(SingularPersistentAttributeEmbedded embeddableAttribute, CallbackType callbackType, ReflectionManager reflectionManager) { final XClass embeddableXClass = reflectionManager.toXClass( embeddableAttribute.getJavaTypeDescriptor().getJavaType() ); for ( final XMethod xMethod : methods ) { if ( xMethod.isAnnotationPresent( callbackType.getCallbackAnnotation() ) ) { Method method = reflectionManager.toMethod( xMethod ); final String methodName = method.getName(); if ( !callbacksMethodNames.contains( methodName ) ) {
public static void bindPackage(String packageName, MetadataBuildingContext context) { XPackage pckg; try { pckg = context.getBootstrapContext().getReflectionManager().packageForName( packageName );
final XMethod xMethod = methods.get( i ); if ( xMethod.isAnnotationPresent( annotation ) ) { Method method = reflectionManager.toMethod( xMethod ); final String methodName = method.getName(); if ( ! callbacksMethodNames.contains( methodName ) ) { List<Class> defaultListeners = (List<Class>) reflectionManager.getDefaults().get( EntityListeners.class ); Callback callback = null; if ( listener != null ) { XClass xListener = reflectionManager.toXClass( listener ); callbacksMethodNames = new ArrayList<String>(); do { final XMethod xMethod = methods.get( i ); if ( xMethod.isAnnotationPresent( annotation ) ) { final Method method = reflectionManager.toMethod( xMethod ); final String methodName = method.getName(); if ( ! callbacksMethodNames.contains( methodName ) ) {
public static boolean isDefault(XClass clazz, MetadataBuildingContext context) { return context.getBootstrapContext().getReflectionManager().equals( clazz, void.class ); }
@Override public void prepare() { // use any persistence-unit-defaults defined in orm.xml ( (JpaOrmXmlPersistenceUnitDefaultAware) rootMetadataBuildingContext.getBuildingOptions() ).apply( new JpaOrmXmlPersistenceUnitDefaults() { final Map persistenceUnitDefaults = reflectionManager.getDefaults(); @Override public String getDefaultSchemaName() { return StringHelper.nullIfEmpty( (String) persistenceUnitDefaults.get( "schema" ) ); } @Override public String getDefaultCatalogName() { return StringHelper.nullIfEmpty( (String) persistenceUnitDefaults.get( "catalog" ) ); } @Override public boolean shouldImplicitlyQuoteIdentifiers() { final Object isDelimited = persistenceUnitDefaults.get( "delimited-identifier" ); return isDelimited != null && isDelimited == Boolean.TRUE; } } ); rootMetadataBuildingContext.getMetadataCollector().getDatabase().adjustDefaultNamespace( rootMetadataBuildingContext.getBuildingOptions().getMappingDefaults().getImplicitCatalogName(), rootMetadataBuildingContext.getBuildingOptions().getMappingDefaults().getImplicitSchemaName() ); AnnotationBinder.bindDefaults( rootMetadataBuildingContext ); for ( String annotatedPackage : annotatedPackages ) { AnnotationBinder.bindPackage( annotatedPackage, rootMetadataBuildingContext ); } }
public ComponentPropertiesSource(ReflectionManager reflectionManager, Component component) { try { this.xclass = reflectionManager.classForName( component.getComponentClassName() ); } catch ( ClassLoadingException e ) { throw new MappingException( e ); } this.component = component; }
@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 ); } }
public static void bindPackage(String packageName, ExtendedMappings mappings) { XPackage pckg; try { pckg = mappings.getReflectionManager().packageForName( packageName ); } catch ( ClassNotFoundException cnf ) { log.warn( "Package not found or wo package-info.java: {}", packageName ); return; } if ( pckg.isAnnotationPresent( SequenceGenerator.class ) ) { SequenceGenerator ann = pckg.getAnnotation( SequenceGenerator.class ); IdGenerator idGen = buildIdGenerator( ann, mappings ); mappings.addGenerator( idGen ); log.trace( "Add sequence generator with name: {}", idGen.getName() ); } if ( pckg.isAnnotationPresent( TableGenerator.class ) ) { TableGenerator ann = pckg.getAnnotation( TableGenerator.class ); IdGenerator idGen = buildIdGenerator( ann, mappings ); mappings.addGenerator( idGen ); } bindGenericGenerators( pckg, mappings ); bindQueries( pckg, mappings ); bindFilterDefs( pckg, mappings ); bindTypeDefs( pckg, mappings ); bindFetchProfiles( pckg, mappings ); BinderHelper.bindAnyMetaDefs( pckg, mappings ); }
private void categorizeAnnotatedClass(Class annotatedClass, AttributeConverterManager attributeConverterManager) { final XClass xClass = reflectionManager.toXClass( annotatedClass ); // categorize it, based on assumption it does not fall into multiple categories if ( xClass.isAnnotationPresent( Converter.class ) ) { //noinspection unchecked attributeConverterManager.addAttributeConverter( annotatedClass ); } else if ( xClass.isAnnotationPresent( Entity.class ) || xClass.isAnnotationPresent( MappedSuperclass.class ) ) { xClasses.add( xClass ); } else if ( xClass.isAnnotationPresent( Embeddable.class ) ) { xClasses.add( xClass ); } else { log.debugf( "Encountered a non-categorized annotated class [%s]; ignoring", annotatedClass.getName() ); } }