Search in sources :

Example 76 with DynamicType

use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.

the class MetadataProject method createDynamicClasses.

/**
 * INTERNAL:
 * Create the dynamic class using JPA metadata processed descriptors. Called
 * at deploy time after all metadata processing has completed.
 */
public void createDynamicClasses(ClassLoader loader) {
    if (!m_virtualClasses.isEmpty()) {
        if (DynamicClassLoader.class.isAssignableFrom(loader.getClass())) {
            DynamicClassLoader dcl = (DynamicClassLoader) loader;
            // Create the dynamic classes.
            Map<String, MetadataDescriptor> dynamicClasses = new HashMap<String, MetadataDescriptor>();
            for (ClassAccessor accessor : m_virtualClasses.values()) {
                createDynamicClass(accessor.getDescriptor(), dynamicClasses, dcl);
            }
            // Create the dynamic types.
            Map<String, DynamicType> dynamicTypes = new HashMap<String, DynamicType>();
            for (MetadataDescriptor descriptor : dynamicClasses.values()) {
                createDynamicType(descriptor, dynamicTypes, dcl);
            }
        } else {
            // have a dynamic class loader throw an exception.
            throw ValidationException.invalidClassLoaderForDynamicPersistence();
        }
    }
    createRestInterfaces(loader);
}
Also used : DynamicClassLoader(org.eclipse.persistence.dynamic.DynamicClassLoader) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ClassAccessor(org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor) DynamicType(org.eclipse.persistence.dynamic.DynamicType)

Aggregations

DynamicType (org.eclipse.persistence.dynamic.DynamicType)76 Test (org.junit.Test)57 DynamicEntity (org.eclipse.persistence.dynamic.DynamicEntity)56 EntityManager (jakarta.persistence.EntityManager)20 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)19 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)15 ReportQuery (org.eclipse.persistence.queries.ReportQuery)15 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)13 JPADynamicHelper (org.eclipse.persistence.jpa.dynamic.JPADynamicHelper)8 DirectToFieldMapping (org.eclipse.persistence.mappings.DirectToFieldMapping)8 HashMap (java.util.HashMap)7 DynamicClassLoader (org.eclipse.persistence.dynamic.DynamicClassLoader)5 OneToManyMapping (org.eclipse.persistence.mappings.OneToManyMapping)4 BufferedReader (java.io.BufferedReader)3 IOException (java.io.IOException)3 InputStreamReader (java.io.InputStreamReader)3 DynamicTypeBuilder (org.eclipse.persistence.dynamic.DynamicTypeBuilder)3 DynamicEntityImpl (org.eclipse.persistence.internal.dynamic.DynamicEntityImpl)3 ReadObjectQuery (org.eclipse.persistence.queries.ReadObjectQuery)3 DynamicHelper (org.eclipse.persistence.dynamic.DynamicHelper)2