diff --git a/foundation/eclipselink.core.test/src/it/java/org/eclipse/persistence/testing/tests/workbenchintegration/IsIsolatedTest.java b/foundation/eclipselink.core.test/src/it/java/org/eclipse/persistence/testing/tests/workbenchintegration/IsIsolatedTest.java index ac2ca68509e..68f33e6e364 100644 --- a/foundation/eclipselink.core.test/src/it/java/org/eclipse/persistence/testing/tests/workbenchintegration/IsIsolatedTest.java +++ b/foundation/eclipselink.core.test/src/it/java/org/eclipse/persistence/testing/tests/workbenchintegration/IsIsolatedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -28,7 +28,7 @@ public class IsIsolatedTest extends ProjectClassGeneratorResultFileTest { public IsIsolatedTest() { super(new org.eclipse.persistence.testing.models.employee.relational.EmployeeProject(), - "descriptor.setIsIsolated(true);"); + "descriptor.setCacheIsolation(CacheIsolationType.ISOLATED);"); setDescription("Test addDescriptorPropertyLines method -> the setIsIsolated"); } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/CMPPolicy.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/CMPPolicy.java index 8caeffa7326..8fb802ee84a 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/CMPPolicy.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/CMPPolicy.java @@ -603,7 +603,7 @@ protected boolean isSingleKey(KeyElementAccessor[] pkElementArray){ /** * INTERNAL: - * This is the interface used to encapsulate the the type of key class element + * This is the interface used to encapsulate the type of key class element */ protected interface KeyElementAccessor { String getAttributeName(); diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/ClassDescriptor.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/ClassDescriptor.java index a1cd27b4097..42d649c2bf4 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/ClassDescriptor.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/ClassDescriptor.java @@ -1475,7 +1475,7 @@ public Object clone() { public void convertClassNamesToClasses(ClassLoader classLoader) { //Class redirectorClass = null; - if (getJavaClassName() != null) { + if (getJavaClass() == null && getJavaClassName() != null) { final Class descriptorClass = PrivilegedAccessHelper.callDoPrivilegedWithException( () -> org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getClassForName(getJavaClassName(), true, classLoader), (ex) -> ValidationException.classNotFoundWhileConvertingClassNames(getJavaClassName(), ex) @@ -1483,7 +1483,7 @@ public void convertClassNamesToClasses(ClassLoader classLoader) { setJavaClass(descriptorClass); } - if (getAmendmentClassName() != null) { + if (getAmendmentClass() == null && getAmendmentClassName() != null) { final Class amendmentClass = PrivilegedAccessHelper.callDoPrivilegedWithException( () -> org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getClassForName(getAmendmentClassName(), true, classLoader), (ex) -> ValidationException.classNotFoundWhileConvertingClassNames(getAmendmentClassName(), ex) diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/codegen/ClassDefinition.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/codegen/ClassDefinition.java index 1d225ad19b5..4c76341e7e1 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/codegen/ClassDefinition.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/codegen/ClassDefinition.java @@ -31,7 +31,7 @@ */ public class ClassDefinition extends CodeDefinition { protected String packageName; - protected List imports; + protected Set imports; protected int type; public static final int CLASS_TYPE = 1; public static final int INTERFACE_TYPE = 2; @@ -39,16 +39,16 @@ public class ClassDefinition extends CodeDefinition { protected List interfaces; protected List attributes; protected List methods; - protected List innerClasses; + protected Set innerClasses; public ClassDefinition() { this.packageName = ""; - this.imports = new ArrayList<>(3); + this.imports = new TreeSet<>(); this.type = CLASS_TYPE; this.interfaces = new ArrayList<>(3); this.attributes = new ArrayList<>(); this.methods = new ArrayList<>(); - this.innerClasses = new ArrayList<>(3); + this.innerClasses = new TreeSet<>(Comparator.comparing(CodeDefinition::getName)); } public void addAttribute(AttributeDefinition attribute) { @@ -60,9 +60,7 @@ public void addAttribute(AttributeDefinition attribute) { * "{packageName}.{shortName or '*'}" */ public void addImport(String importStatement) { - if (!getImports().contains(importStatement)) { - getImports().add(importStatement); - } + getImports().add(importStatement); } private void addImports(Map> typeNameMap) { @@ -80,11 +78,11 @@ private void addImports(Map> typeNameMap) { } } } - - sortImports(); } public void addInnerClass(ClassDefinition classDefinition) { + imports.addAll(classDefinition.imports); + classDefinition.imports.clear(); getInnerClasses().add(classDefinition); } @@ -163,11 +161,11 @@ protected List getAttributes() { return attributes; } - protected List getImports() { + protected Set getImports() { return imports; } - protected List getInnerClasses() { + protected Set getInnerClasses() { return innerClasses; } @@ -203,7 +201,7 @@ protected void replaceInterface(String oldInterfaceName, String newInterfaceName } } - private void setImports(List imports) { + private void setImports(Set imports) { this.imports = imports; } @@ -227,10 +225,6 @@ public void setType(int type) { this.type = type; } - protected void sortImports() { - setImports(new ArrayList<>(new TreeSet<>(getImports()))); - } - protected void sortMethods() { Comparator comparison = (first, second) -> { if (first.isConstructor()) { diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/codegen/CodeGenerator.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/codegen/CodeGenerator.java index 3e608df2240..323e03713f1 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/codegen/CodeGenerator.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/codegen/CodeGenerator.java @@ -65,7 +65,7 @@ public void setOutput(Writer output) { } public void tab() { - write("\t"); + write(" "); } public void tab(int indent) { diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedVector.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedVector.java index 607131f1963..559fcab7da1 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedVector.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedVector.java @@ -685,9 +685,6 @@ public void forEach(Consumer action) { throw new ConcurrentModificationException(); } - /** - * @throws NullPointerException {@inheritDoc} - */ @Override public void replaceAll(UnaryOperator operator) { Objects.requireNonNull(operator); diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/ArrayListContainerPolicy.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/ArrayListContainerPolicy.java index 5ad3b02a10f..275e1b83abf 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/ArrayListContainerPolicy.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/ArrayListContainerPolicy.java @@ -91,4 +91,10 @@ public Object containerInstance() { public Object containerInstance(int initialCapacity) { return new ArrayList<>(initialCapacity); } + + @Override + public Class getPolicyContainerClass() { + return ArrayList.class; + } + } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/IndirectListContainerPolicy.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/IndirectListContainerPolicy.java index 300f0376116..6f66a129a82 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/IndirectListContainerPolicy.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/IndirectListContainerPolicy.java @@ -90,4 +90,10 @@ public Object containerInstance() { public Object containerInstance(int initialCapacity) { return IndirectCollectionsFactory.createIndirectList(initialCapacity); } + + @Override + public Class getPolicyContainerClass() { + return IndirectCollectionsFactory.IndirectList_Class; + } + } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/InterfaceContainerPolicy.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/InterfaceContainerPolicy.java index 4df4b6fc1f4..b2d80e43540 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/InterfaceContainerPolicy.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/InterfaceContainerPolicy.java @@ -128,7 +128,7 @@ public Object cloneFor(Object container) { @Override public void convertClassNamesToClasses(ClassLoader classLoader){ super.convertClassNamesToClasses(classLoader); - if (getContainerClassName() == null){ + if (getContainerClass() != null) { return; } Class containerClass = null; @@ -360,7 +360,9 @@ public void setCloneMethod(Method cloneMethod) { @Override public void setContainerClass(Class containerClass) { this.containerClass = containerClass; - initializeConstructor(); + if (getPolicyContainerClass() == null || containerClass != getPolicyContainerClass()) { + initializeConstructor(); + } } @Override @@ -385,4 +387,13 @@ public Object buildContainerFromVector(Vector vector, AbstractSession session) { protected Object toStringInfo() { return getContainerClass(); } + + /** + * INTERNAL: + * Get the default {@code Collection} class used by the container policy. + */ + protected Class getPolicyContainerClass() { + return null; + } + } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/VectorContainerPolicy.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/VectorContainerPolicy.java index 3de216b2bb9..1b14c5d77e5 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/VectorContainerPolicy.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/VectorContainerPolicy.java @@ -58,11 +58,11 @@ public Object cloneFor(Object container) { } if (container.getClass() == Vector.class) { - return ((Vector) container).clone(); + return ((Vector) container).clone(); } // Could potentially be another Collection type as well. - return new Vector<>((Collection) container); + return new Vector<>((Collection) container); } /** @@ -91,4 +91,9 @@ public Object containerInstance() { public Object containerInstance(int initialCapacity) { return new Vector<>(initialCapacity); } + + @Override + public Class getPolicyContainerClass() { + return Vector.class; + } } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/security/SecurableObjectHolder.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/security/SecurableObjectHolder.java index 8c5993fa20f..2890f1210d7 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/security/SecurableObjectHolder.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/security/SecurableObjectHolder.java @@ -28,9 +28,6 @@ */ public class SecurableObjectHolder { - /** The JCE encryption class name */ - private final static String JCE_ENCRYPTION_CLASS_NAME = "org.eclipse.persistence.internal.security.JCEEncryptor"; - /** The encryption class name **/ private String m_securableClassName; @@ -73,28 +70,29 @@ public boolean hasSecurableObject() { */ private void initSecurableObject() { boolean initPassThroughEncryptor = false; - - if (m_securableClassName == null) { - // Since we are defaulting, hence, assuming they can initialize the JCE - // libraries, if the init fails, this flag tells us to assume no encryption. - // However, if the JCE init does work, the JCEEncryptor will need to - // determine that a password was not encrypted by it, therefore, assume - // clear text. See JCEEncryptor. - initPassThroughEncryptor = true; - m_securableClassName = JCE_ENCRYPTION_CLASS_NAME; - } - try { + if (m_securableClassName == null || JCEEncryptor.class.getName().equals(m_securableClassName)) { + // Since we are defaulting, hence, assuming they can initialize the JCE + // libraries, if the init fails, this flag tells us to assume no encryption. + // However, if the JCE init does work, the JCEEncryptor will need to + // determine that a password was not encrypted by it, therefore, assume + // clear text. See JCEEncryptor. + initPassThroughEncryptor = m_securableClassName == null; + m_securableObject = new JCEEncryptor(); + return; + } + ConversionManager cm = ConversionManager.getDefaultManager(); - Class securableClass = cm.convertObject(m_securableClassName, Class.class); - if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ + @SuppressWarnings({"unchecked"}) + Class securableClass = cm.convertObject(m_securableClassName, Class.class); + if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) { try { - m_securableObject = (Securable)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(securableClass)); + m_securableObject = AccessController.doPrivileged(new PrivilegedNewInstanceFromClass<>(securableClass)); } catch (PrivilegedActionException exception) { throw exception.getException(); } } else { - m_securableObject = (Securable)PrivilegedAccessHelper.newInstanceFromClass(securableClass); + m_securableObject = PrivilegedAccessHelper.newInstanceFromClass(securableClass); } } catch (Throwable e) { if (initPassThroughEncryptor) {// default failed, so perform no encryption. diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/sessions/AbstractSession.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/sessions/AbstractSession.java index 98b4f196429..ae59a6971f7 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/sessions/AbstractSession.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/sessions/AbstractSession.java @@ -136,7 +136,6 @@ /** * Implementation of org.eclipse.persistence.sessions.Session * The public interface should be used. - * @see org.eclipse.persistence.sessions.Session * *

* Purpose: Define the interface and common protocol of an EclipseLink compliant session. @@ -161,6 +160,7 @@ *

  • Identity maps and caching. * * @see DatabaseSessionImpl + * @see org.eclipse.persistence.sessions.Session */ public abstract class AbstractSession extends CoreAbstractSession implements org.eclipse.persistence.sessions.Session, CommandProcessor, Serializable, Cloneable { /** ExceptionHandler handles database exceptions. */ @@ -438,7 +438,7 @@ public JPAQueryBuilder getQueryBuilder() { /** * INTERNAL - * Set the query builder used to parser JPQL. + * Set the query builder used to parse JPQL. */ public void setQueryBuilder(JPAQueryBuilder queryBuilder) { this.queryBuilder = queryBuilder; diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/AggregateObjectMapping.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/AggregateObjectMapping.java index 40e8b1aa452..aaa006299d3 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/AggregateObjectMapping.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/AggregateObjectMapping.java @@ -153,13 +153,20 @@ public class AggregateObjectMapping extends AggregateMapping implements Relation */ protected List mapsIdMappings; + /** + * List of map id attributes that need thir mapping to be set to read only at initialize + * time on their cloned aggregate mappings. + */ + protected List mapsIdMappingAttributes; + /** * Default constructor. */ public AggregateObjectMapping() { - aggregateToSourceFields = new HashMap(5); + aggregateToSourceFields = new HashMap<>(5); nestedFieldTranslations = new HashMap<>(); mapsIdMappings = new ArrayList<>(); + mapsIdMappingAttributes = new ArrayList<>(); overrideManyToManyMappings = new ArrayList<>(); overrideUnidirectionalOneToManyMappings = new ArrayList<>(); converters = new HashMap<>(); @@ -246,6 +253,17 @@ public void addFieldTranslation(DatabaseField sourceField, String aggregateField */ public void addMapsIdMapping(DatabaseMapping mapping) { mapsIdMappings.add(mapping); + addMapsIdMappingAttribute(mapping.getAttributeName()); + } + + /** + * INTERNAL: + * In JPA users may specify a maps id attribute mapping on a shared embeddable + * descriptor. Mappings for these attributes need to be set to read-only + * at initialize time, after the reference descriptor is cloned. + */ + public void addMapsIdMappingAttribute(String attribute) { + mapsIdMappingAttributes.add(attribute); } /** @@ -1269,6 +1287,15 @@ protected Object getMatchingBackupAttributeValue(WriteObjectQuery query, Object return getAttributeValueFromObject(query.getBackupClone()); } + /** + * INTERNAL: + * Return the list of map id attributes that need their mapping to be set to read only + * at initialize time on their cloned aggregate mappings. + */ + public List getMapsIdMappingAttributes() { + return mapsIdMappingAttributes; + } + /** * INTERNAL: * Return the query that is used when this mapping is part of a joined relationship @@ -1412,8 +1439,8 @@ public void initialize(AbstractSession session) throws DescriptorException { } // Mark any mapsId mappings as read-only. - for (DatabaseMapping mapsIdMapping : mapsIdMappings) { - DatabaseMapping mapping = clonedDescriptor.getMappingForAttributeName(mapsIdMapping.getAttributeName()); + for (String attribute : getMapsIdMappingAttributes()) { + DatabaseMapping mapping = clonedDescriptor.getMappingForAttributeName(attribute); if (mapping != null) { mapping.setIsReadOnly(true); diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/ForeignReferenceMapping.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/ForeignReferenceMapping.java index 434bb1f5372..59f6d76216e 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/ForeignReferenceMapping.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/ForeignReferenceMapping.java @@ -421,7 +421,7 @@ public void convertClassNamesToClasses(ClassLoader classLoader){ super.convertClassNamesToClasses(classLoader); // DirectCollection mappings don't require a reference class. - if (getReferenceClassName() != null) { + if (getReferenceClass() == null && getReferenceClassName() != null) { Class referenceClass = null; try{ if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/queries/ObjectBuildingQuery.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/queries/ObjectBuildingQuery.java index 4724d0ccd98..f852b518369 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/queries/ObjectBuildingQuery.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/queries/ObjectBuildingQuery.java @@ -151,21 +151,23 @@ protected void clonedQueryExecutionComplete(DatabaseQuery query, AbstractSession @Override public void convertClassNamesToClasses(ClassLoader classLoader){ super.convertClassNamesToClasses(classLoader); - Class referenceClass = null; - try{ - if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ - try { - referenceClass = AccessController.doPrivileged(new PrivilegedClassForName<>(getReferenceClassName(), true, classLoader)); - } catch (PrivilegedActionException exception) { - throw ValidationException.classNotFoundWhileConvertingClassNames(getReferenceClassName(), exception.getException()); + if (getReferenceClass() == null) { + Class referenceClass = null; + try { + if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) { + try { + referenceClass = AccessController.doPrivileged(new PrivilegedClassForName<>(getReferenceClassName(), true, classLoader)); + } catch (PrivilegedActionException exception) { + throw ValidationException.classNotFoundWhileConvertingClassNames(getReferenceClassName(), exception.getException()); + } + } else { + referenceClass = PrivilegedAccessHelper.getClassForName(getReferenceClassName(), true, classLoader); } - } else { - referenceClass = PrivilegedAccessHelper.getClassForName(getReferenceClassName(), true, classLoader); + } catch (ClassNotFoundException exc) { + throw ValidationException.classNotFoundWhileConvertingClassNames(getReferenceClassName(), exc); } - } catch (ClassNotFoundException exc){ - throw ValidationException.classNotFoundWhileConvertingClassNames(getReferenceClassName(), exc); + setReferenceClass(referenceClass); } - setReferenceClass(referenceClass); } /** diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/DatabaseLogin.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/DatabaseLogin.java index 3f08c4d7316..9de24eb24f2 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/DatabaseLogin.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/DatabaseLogin.java @@ -1205,7 +1205,8 @@ public boolean shouldUseStringBinding() { public String toString() { StringWriter stringWriter = new StringWriter(); PrintWriter writer = new PrintWriter(stringWriter); - writer.println("DatabaseLogin("); + writer.print(getClass().getSimpleName()); + writer.println("("); writer.println("\t" + ToStringLocalization.buildMessage("platform", null) + "=>" + getDatasourcePlatform()); writer.println("\t" + ToStringLocalization.buildMessage("user_name", null) + "=> \"" + getUserName() + "\""); writer.print("\t"); diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/DatasourceLogin.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/DatasourceLogin.java index f39e8c94509..7c8a581dbb9 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/DatasourceLogin.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/DatasourceLogin.java @@ -504,46 +504,50 @@ public void setDatasourcePlatform(Platform platform) { public String getPlatformClassName() { return getDatasourcePlatform().getClass().getName(); } + /** * INTERNAL: * Set the name of the Platform to be used. * Creates a new instance of the specified Class. */ + @SuppressWarnings({"unchecked"}) public void setPlatformClassName(String platformClassName) throws ValidationException { - // Handle old Oracle platform conversion. - if (platformClassName.equals("org.eclipse.persistence.platform.database.oracle.OraclePlatform")) { - platformClassName = "org.eclipse.persistence.platform.database.OraclePlatform"; - } + if (platform == null || !(platform.getClass().getName().equals(platformClassName))) { + // Handle old Oracle platform conversion. + if (platformClassName.equals("org.eclipse.persistence.platform.database.oracle.OraclePlatform")) { + platformClassName = "org.eclipse.persistence.platform.database.OraclePlatform"; + } - Class platformClass = null; - try { - //First try loading with the Login's class loader - platformClass = this.getClass().getClassLoader().loadClass(platformClassName); - } catch(Throwable cne) { - //next try using ConversionManager + Class platformClass = null; try { - platformClass = ConversionManager.loadClass(platformClassName); - } catch(Throwable cne2) { - //set the original exception - cne2.addSuppressed(cne); - //if still not found, throw exception - throw ValidationException.platformClassNotFound(cne2, platformClassName); + //First try loading with the Login's class loader + platformClass = (Class) this.getClass().getClassLoader().loadClass(platformClassName); + } catch (Throwable cne) { + //next try using ConversionManager + try { + platformClass = ConversionManager.loadClass(platformClassName); + } catch (Throwable cne2) { + //set the original exception + cne2.addSuppressed(cne); + //if still not found, throw exception + throw ValidationException.platformClassNotFound(cne2, platformClassName); + } } - } - Platform platform = null; - try { - if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ - platform = (Platform)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass<>(platformClass)); - } else { - platform = (Platform)PrivilegedAccessHelper.newInstanceFromClass(platformClass); + Platform platform = null; + try { + if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) { + platform = AccessController.doPrivileged(new PrivilegedNewInstanceFromClass<>(platformClass)); + } else { + platform = PrivilegedAccessHelper.newInstanceFromClass(platformClass); + } + } catch (PrivilegedActionException exception) { + throw ValidationException.platformClassNotFound(exception.getException(), platformClassName); + } catch (Throwable cne) { + throw ValidationException.platformClassNotFound(cne, platformClassName); } - } catch (PrivilegedActionException exception) { - throw ValidationException.platformClassNotFound(exception.getException(), platformClassName); - } catch(Throwable cne) { - throw ValidationException.platformClassNotFound(cne, platformClassName); + usePlatform(platform); } - usePlatform(platform); } /** * INTERNAL: @@ -553,31 +557,33 @@ public void setPlatformClassName(String platformClassName) throws ValidationExce * setPlatformClassName method with no classloader. * @see #setPlatformClassName(String platformClassName) */ + @SuppressWarnings({"unchecked"}) public void setPlatformClassName(String platformClassName, ClassLoader loader) throws ValidationException { - boolean exceptionCaught = false; - Class platformClass = null; - try { - Platform platform = null; - if (loader != null) { - platformClass = loader.loadClass(platformClassName); - if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ - try { - platform = (Platform)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass<>(platformClass)); - } catch (PrivilegedActionException exception) { - throw ValidationException.platformClassNotFound(exception.getException(), platformClassName); - } - } else { - platform = (Platform)PrivilegedAccessHelper.newInstanceFromClass(platformClass); + if (platform == null || !(platform.getClass().getName().equals(platformClassName))) { + boolean exceptionCaught = false; + Class platformClass = null; + try { + Platform platform = null; + if (loader != null) { + platformClass = (Class) loader.loadClass(platformClassName); + if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) { + try { + platform = AccessController.doPrivileged(new PrivilegedNewInstanceFromClass<>(platformClass)); + } catch (PrivilegedActionException exception) { + throw ValidationException.platformClassNotFound(exception.getException(), platformClassName); + } + } else { + platform = PrivilegedAccessHelper.newInstanceFromClass(platformClass); + } } + usePlatform(platform); + } catch (Exception cne) { + exceptionCaught = true; + } + if (exceptionCaught || (loader == null)) { + //attempt to load with default classloader + this.setPlatformClassName(platformClassName); } - usePlatform(platform); - } catch(Exception cne) { - exceptionCaught = true; - } - if (exceptionCaught || (loader == null)) - { - //attempt to load with default classloader - this.setPlatformClassName(platformClassName); } } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/factories/ProjectClassGenerator.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/factories/ProjectClassGenerator.java index 4077b67c42a..9baf720c48a 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/factories/ProjectClassGenerator.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/factories/ProjectClassGenerator.java @@ -61,6 +61,8 @@ import org.eclipse.persistence.internal.indirection.NoIndirectionPolicy; import org.eclipse.persistence.internal.indirection.ProxyIndirectionPolicy; import org.eclipse.persistence.internal.indirection.TransparentIndirectionPolicy; +import org.eclipse.persistence.internal.queries.ContainerPolicy; +import org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy; import org.eclipse.persistence.internal.queries.ReportItem; import org.eclipse.persistence.internal.sessions.factories.DirectToXMLTypeMappingHelper; import org.eclipse.persistence.mappings.AggregateCollectionMapping; @@ -74,6 +76,7 @@ import org.eclipse.persistence.mappings.ManyToManyMapping; import org.eclipse.persistence.mappings.OneToManyMapping; import org.eclipse.persistence.mappings.OneToOneMapping; +import org.eclipse.persistence.mappings.RelationTableMechanism; import org.eclipse.persistence.mappings.TransformationMapping; import org.eclipse.persistence.mappings.VariableOneToOneMapping; import org.eclipse.persistence.mappings.converters.Converter; @@ -81,6 +84,7 @@ import org.eclipse.persistence.mappings.converters.SerializedObjectConverter; import org.eclipse.persistence.mappings.converters.TypeConversionConverter; import org.eclipse.persistence.mappings.foundation.AbstractDirectMapping; +import org.eclipse.persistence.mappings.foundation.MapKeyMapping; import org.eclipse.persistence.mappings.querykeys.DirectQueryKey; import org.eclipse.persistence.mappings.querykeys.QueryKey; import org.eclipse.persistence.queries.DatabaseQuery; @@ -192,6 +196,9 @@ protected void addAggregateObjectMappingLines(NonreflectiveMethodDefinition meth //may need to account for delimiting on the sourceField in the future method.addLine(mappingName + ".addFieldNameTranslation(\"" + sourceField.getQualifiedName() + "\", \"" + aggregateFieldName + "\");"); } + for (String attribute: mapping.getMapsIdMappingAttributes()) { + method.addLine(mappingName + ".addMapsIdMappingAttribute(\"" + attribute + "\");"); + } } protected void addCacheInvalidationPolicyLines(NonreflectiveMethodDefinition method, ClassDescriptor descriptor) { @@ -318,7 +325,7 @@ protected void addDescriptorPropertyLines(NonreflectiveMethodDefinition method, // Isolated Session support if (descriptor.getCachePolicy().isIsolated()) { - method.addLine("descriptor.setIsIsolated(true);"); + method.addLine("descriptor.setCacheIsolation(CacheIsolationType.ISOLATED);"); } // Refreshing @@ -349,17 +356,7 @@ protected void addDescriptorPropertyLines(NonreflectiveMethodDefinition method, } // Instantiation - if (!descriptor.getInstantiationPolicy().isUsingDefaultConstructor()) { - if (descriptor.getInstantiationPolicy().getFactoryClassName() != null) { - if (descriptor.getInstantiationPolicy().getFactoryMethodName() != null) { - method.addLine("descriptor.useFactoryInstantiationPolicy(" + descriptor.getInstantiationPolicy().getFactoryClassName() + ".class, \"" + descriptor.getInstantiationPolicy().getMethodName() + "\", \"" + descriptor.getInstantiationPolicy().getFactoryMethodName() + "\");"); - } else { - method.addLine("descriptor.useFactoryInstantiationPolicy(" + descriptor.getInstantiationPolicy().getFactoryClassName() + ".class, \"" + descriptor.getInstantiationPolicy().getMethodName() + "\");"); - } - } else { - method.addLine("descriptor.useMethodInstantiationPolicy(\"" + descriptor.getInstantiationPolicy().getMethodName() + "\");"); - } - } + addInstantiationPolicyLines(method, descriptor); // Amendment if (descriptor.getAmendmentClassName() != null) { @@ -394,6 +391,21 @@ protected void addDirectCollectionMappingLines(NonreflectiveMethodDefinition met } method.addLine(mappingName + ".setDirectFieldName(\"" + mapping.getDirectFieldName() + "\");"); + if (mapping.getDirectField().getTypeName() != null) { + method.addLine(mappingName + ".setDirectFieldClassification(" + mapping.getDirectField().getTypeName() + ".class);"); + } else if (mapping.getDirectField().getType() != null) { + method.addLine(mappingName + ".setDirectFieldClassification(" + mapping.getDirectField().getType().getName() + ".class);"); + } + + if (mapping.getAttributeClassificationName() != null) { + method.addLine(mappingName + ".setAttributeClassification(" + mapping.getAttributeClassificationName() + ".class);"); + } else if (mapping.getAttributeClassification() != null) { + method.addLine(mappingName + ".setAttributeClassification(" + mapping.getAttributeClassification().getName() + ".class);"); + } else if (mapping.getDirectField().getTypeName() != null) { + method.addLine(mappingName + ".setAttributeClassification(" + mapping.getDirectField().getTypeName() + ".class);"); + } else if (mapping.getDirectField().getType() != null) { + method.addLine(mappingName + ".setAttributeClassification(" + mapping.getDirectField().getType().getName() + ".class);"); + } Enumeration sourceKeysEnum = mapping.getSourceKeyFields().elements(); Enumeration referenceKeysEnum = mapping.getReferenceKeyFields().elements(); @@ -413,11 +425,18 @@ protected void addDirectCollectionMappingLines(NonreflectiveMethodDefinition met } protected void addDirectMapMappingLines(NonreflectiveMethodDefinition method, String mappingName, DirectMapMapping mapping) { - DatabaseField directKeyField = mapping.getDirectKeyField(); + DatabaseField directKeyField = mapping.getDirectKeyField(); if(directKeyField != null) { method.addLine(mappingName + ".setDirectKeyFieldName(\"" + directKeyField.getQualifiedName() + "\");"); } + ContainerPolicy containerPolicy = mapping.getContainerPolicy(); + if (containerPolicy.isMappedKeyMapPolicy()) { + method.addLine(""); + addMappedKeyMapContainerPolicyLines(method, mappingName, (MappedKeyMapContainerPolicy) containerPolicy); + method.addLine(""); + } + Converter converter = mapping.getKeyConverter(); if (converter != null) { addConverterLines(method, mappingName + "KeyConverter", converter); @@ -425,6 +444,42 @@ protected void addDirectMapMappingLines(NonreflectiveMethodDefinition method, St } } + protected void addMappedKeyMapContainerPolicyLines(NonreflectiveMethodDefinition method, String mappingName, MappedKeyMapContainerPolicy policy) { + MapKeyMapping keyMapping = policy.getKeyMapping(); + String keyMappingName = mappingName + "KeyMapping"; + String keyMappingClassName = keyMapping.getClass().getName(); + String keyMappingPackageName = keyMappingClassName.substring(0, keyMappingClassName.lastIndexOf('.')); + if (keyMappingPackageName.equals("org.eclipse.persistence.mappings")) { + keyMappingClassName = keyMapping.getClass().getSimpleName(); + } + method.addLine(keyMappingClassName + " " + keyMappingName + " = new " + keyMappingClassName + "();"); + + DatabaseMapping dm = (DatabaseMapping) keyMapping; + if (dm.isReadOnly()) { + method.addLine(keyMappingName + ".readOnly();"); + } + if (dm.isOneToOneMapping()) { + addOneToOneMappingLines(method, keyMappingName, (OneToOneMapping) dm); + } else if (dm.isAggregateObjectMapping()) { + addAggregateObjectMappingLines(method, keyMappingName, (AggregateObjectMapping) dm); + } else if (dm.isDirectToFieldMapping()) { + if (dm.getDescriptor() != null && dm.getDescriptor().isAggregateDescriptor()) { + method.addLine(keyMappingName + ".setFieldName(\"" + dm.getField().getName() + "\");"); + } else { + method.addLine(keyMappingName + ".setFieldName(\"" + dm.getField().getQualifiedName() + "\");"); + } + } + + method.addLine(keyMappingName + ".setDescriptor(descriptor);"); + + method.addLine(""); + String policyName = mappingName + "ContainerPolicy"; + method.addLine("MappedKeyMapContainerPolicy " + policyName + " = new MappedKeyMapContainerPolicy(" + policy.getContainerClassName() + ".class);"); + method.addLine(policyName + ".setKeyMapping(" + keyMappingName + ");"); + method.addLine(policyName + ".setValueMapping((MapComponentMapping) " + mappingName + ");"); + method.addLine(mappingName + ".setContainerPolicy(" + policyName + ");"); + } + protected void addFetchGroupManagerLine(NonreflectiveMethodDefinition method, ClassDescriptor descriptor) { if (descriptor.getFetchGroupManager() == null) { return; @@ -580,6 +635,12 @@ protected void addForeignReferenceMappingLines(NonreflectiveMethodDefinition met } else { method.addLine(mappingName + ".useMapClass(" + collectionClassName + ".class, \"" + keyMethodName + "\");"); } + ContainerPolicy containerPolicy = mapping.getContainerPolicy(); + if (containerPolicy.isMappedKeyMapPolicy()) { + method.addLine(""); + addMappedKeyMapContainerPolicyLines(method, mappingName, (MappedKeyMapContainerPolicy) containerPolicy); + method.addLine(""); + } } // Ordering. @@ -730,15 +791,7 @@ protected void addMappingLines(NonreflectiveMethodDefinition method, DatabaseMap mappingClassName = mapping.getClass().getSimpleName(); } method.addLine(mappingClassName + " " + mappingName + " = new " + mappingClassName + "();"); - if (!mapping.isWriteOnly()) { - method.addLine(mappingName + ".setAttributeName(\"" + mapping.getAttributeName() + "\");"); - if (mapping.getGetMethodName() != null) { - method.addLine(mappingName + ".setGetMethodName(\"" + mapping.getGetMethodName() + "\");"); - } - if (mapping.getSetMethodName() != null) { - method.addLine(mappingName + ".setSetMethodName(\"" + mapping.getSetMethodName() + "\");"); - } - } + addMappingAccessorLines(method, mappingName, mapping); if (mapping.isAbstractDirectMapping()) { AbstractDirectMapping directMapping = (AbstractDirectMapping)mapping; if (mapping.getDescriptor().isAggregateDescriptor()) { @@ -789,6 +842,18 @@ protected void addMappingLines(NonreflectiveMethodDefinition method, DatabaseMap method.addLine("descriptor.addMapping(" + mapping.getAttributeName() + "Mapping);"); } + protected void addMappingAccessorLines(NonreflectiveMethodDefinition method, String mappingName, DatabaseMapping mapping) { + if (!mapping.isWriteOnly()) { + method.addLine(mappingName + ".setAttributeName(\"" + mapping.getAttributeName() + "\");"); + if (mapping.getGetMethodName() != null) { + method.addLine(mappingName + ".setGetMethodName(\"" + mapping.getGetMethodName() + "\");"); + } + if (mapping.getSetMethodName() != null) { + method.addLine(mappingName + ".setSetMethodName(\"" + mapping.getSetMethodName() + "\");"); + } + } + } + protected void addObjectTypeConverterLines(NonreflectiveMethodDefinition method, String converterName, ObjectTypeConverter converter) { if (converter.getDefaultAttributeValue() != null) { method.addLine(converterName + ".setDefaultAttributeValue(" + printString(converter.getDefaultAttributeValue()) + ");"); @@ -817,6 +882,7 @@ protected void addOneToManyMappingLines(NonreflectiveMethodDefinition method, St } } + @SuppressWarnings({"unchecked"}) protected void addOneToOneMappingLines(NonreflectiveMethodDefinition method, String mappingName, OneToOneMapping mapping) { for (DatabaseField sourceField : mapping.getSourceToTargetKeyFields().keySet()) { DatabaseField targetField = mapping.getSourceToTargetKeyFields().get(sourceField); @@ -826,6 +892,46 @@ protected void addOneToOneMappingLines(NonreflectiveMethodDefinition method, Str method.addLine(mappingName + ".addTargetForeignKeyFieldName(\"" + targetField.getQualifiedName() + "\", \"" + sourceField.getQualifiedName() + "\");"); } } + + if (mapping.derivesId()) { + method.addLine(mappingName + ".setDerivesId(true);"); + } + if (mapping.getMapsIdValue() != null) { + method.addLine(mappingName + ".setMapsIdValue(\"" + mapping.getMapsIdValue() + "\");"); + } + if (mapping.getDerivedIdMapping() != null) { + method.addLine(mappingName + ".setDerivedIdMapping(" + mapping.getDerivedIdMapping().getAttributeName() + "Mapping);"); + } + + if (mapping.isJPAId()) { + method.addLine(mappingName + ".setIsJPAId();"); + } + + if (mapping.getRelationTableMechanism() != null) { + RelationTableMechanism mechanism = mapping.getRelationTableMechanism(); + String mechanismName = mappingName + "RelationalTableMechanism"; + method.addLine("RelationTableMechanism " + mechanismName + " = new RelationTableMechanism();"); + method.addLine(mechanismName + ".setRelationTableName(\"" + mechanism.getRelationTableName() + "\");"); + + Iterator relationKeyFieldNames = mechanism.getSourceRelationKeyFieldNames().iterator(); + Iterator keyFieldNames = mechanism.getSourceKeyFieldNames().iterator(); + while (relationKeyFieldNames.hasNext()) { + String relationKeyField = relationKeyFieldNames.next(); + String keyField = keyFieldNames.next(); + method.addLine(mechanismName + ".addSourceRelationKeyFieldName(\"" + relationKeyField + "\", \"" + keyField +"\");"); + } + + relationKeyFieldNames = mechanism.getTargetRelationKeyFieldNames().iterator(); + keyFieldNames = mechanism.getTargetKeyFieldNames().iterator(); + while (relationKeyFieldNames.hasNext()) { + String relationKeyField = relationKeyFieldNames.next(); + String keyField = keyFieldNames.next(); + method.addLine(mechanismName + ".addTargetRelationKeyFieldName(\"" + relationKeyField + "\", \"" + keyField +"\");"); + } + + method.addLine(mappingName + ".setRelationTableMechanism(" + mechanismName + ");"); + } + if (!mapping.shouldVerifyDelete()) { method.addLine(mappingName + ".setShouldVerifyDelete(false);"); } @@ -1479,7 +1585,7 @@ protected NonreflectiveMethodDefinition buildDescriptorMethod(ClassDescriptor de NonreflectiveMethodDefinition method = new NonreflectiveMethodDefinition(); - method.setName("build" + getDescriptorMethodNames().get(descriptor) + "ClassDescriptor"); + method.setName("build" + getDescriptorMethodName(descriptor) + "ClassDescriptor"); method.setReturnType("ClassDescriptor"); // ClassDescriptor @@ -1595,10 +1701,24 @@ protected NonreflectiveMethodDefinition buildDescriptorMethod(ClassDescriptor de return method; } + protected void addInstantiationPolicyLines(NonreflectiveMethodDefinition method, ClassDescriptor descriptor) { + if (!descriptor.getInstantiationPolicy().isUsingDefaultConstructor()) { + if (descriptor.getInstantiationPolicy().getFactoryClassName() != null) { + if (descriptor.getInstantiationPolicy().getFactoryMethodName() != null) { + method.addLine("descriptor.useFactoryInstantiationPolicy(" + descriptor.getInstantiationPolicy().getFactoryClassName() + ".class, \"" + descriptor.getInstantiationPolicy().getMethodName() + "\", \"" + descriptor.getInstantiationPolicy().getFactoryMethodName() + "\");"); + } else { + method.addLine("descriptor.useFactoryInstantiationPolicy(" + descriptor.getInstantiationPolicy().getFactoryClassName() + ".class, \"" + descriptor.getInstantiationPolicy().getMethodName() + "\");"); + } + } else { + method.addLine("descriptor.useMethodInstantiationPolicy(\"" + descriptor.getInstantiationPolicy().getMethodName() + "\");"); + } + } + } + /** * Take an unsorted list of descriptors and sort it so that the order is maintained. */ - private List buildSortedListOfDescriptors(List descriptors) { + protected List buildSortedListOfDescriptors(List descriptors) { List returnDescriptors = Helper.addAllUniqueToList(new ArrayList<>(descriptors.size()), descriptors); returnDescriptors.sort(new DescriptorCompare()); return returnDescriptors; @@ -1749,7 +1869,7 @@ protected void computeDescriptorMethodNames() { /** * PUBLIC: * Generate the project class, output the java source code to the stream or file. - * useUnicode determines if unicode escaped characters for non_ASCII charaters will be used. + * useUnicode determines if unicode escaped characters for non_ASCII characters will be used. */ public void generate(boolean useUnicode) throws ValidationException { if (getOutputWriter() == null) { @@ -1774,7 +1894,7 @@ public void generate(boolean useUnicode) throws ValidationException { /** * PUBLIC: * Generate the project class, output the java source code to the stream or file. - * Unicode escaped characters for non_ASCII charaters will be used. + * Unicode escaped characters for non_ASCII characters will be used. */ public void generate() throws ValidationException { generate(true); @@ -1793,15 +1913,18 @@ protected ClassDefinition generateProjectClass() { classDefinition.setSuperClass("org.eclipse.persistence.sessions.Project"); classDefinition.setPackageName(getPackageName()); + classDefinition.addImport("org.eclipse.persistence.config.*"); classDefinition.addImport("org.eclipse.persistence.sessions.*"); classDefinition.addImport("org.eclipse.persistence.descriptors.*"); classDefinition.addImport("org.eclipse.persistence.descriptors.invalidation.*"); classDefinition.addImport("org.eclipse.persistence.mappings.*"); classDefinition.addImport("org.eclipse.persistence.mappings.converters.*"); + classDefinition.addImport("org.eclipse.persistence.mappings.foundation.MapComponentMapping"); classDefinition.addImport("org.eclipse.persistence.queries.*"); classDefinition.addImport("org.eclipse.persistence.expressions.ExpressionBuilder"); classDefinition.addImport("org.eclipse.persistence.history.HistoryPolicy"); classDefinition.addImport("org.eclipse.persistence.sequencing.*"); + classDefinition.addImport("org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy"); classDefinition.setComment("This class was generated by the TopLink project class generator." + System.lineSeparator() + "It stores the meta-data (descriptors) that define the TopLink mappings." + System.lineSeparator() + "## " + DatasourceLogin.getVersion() + " ##" + System.lineSeparator() + "@see org.eclipse.persistence.sessions.factories.ProjectClassGenerator"); @@ -1834,6 +1957,10 @@ protected Map getDescriptorMethodNames() { return descriptorMethodNames; } + protected String getDescriptorMethodName(ClassDescriptor descriptor) { + return getDescriptorMethodNames().get(descriptor); + + } /** * PUBLIC: * Return the file name that the generate .java file will be output to. diff --git a/jpa/eclipselink.jpa.testapps/jpa.test.metamodel/src/test/java/org/eclipse/persistence/testing/tests/jpa/metamodel/MetamodelTest.java b/jpa/eclipselink.jpa.testapps/jpa.test.metamodel/src/test/java/org/eclipse/persistence/testing/tests/jpa/metamodel/MetamodelTest.java index bad70d824ba..ed8eac567c2 100644 --- a/jpa/eclipselink.jpa.testapps/jpa.test.metamodel/src/test/java/org/eclipse/persistence/testing/tests/jpa/metamodel/MetamodelTest.java +++ b/jpa/eclipselink.jpa.testapps/jpa.test.metamodel/src/test/java/org/eclipse/persistence/testing/tests/jpa/metamodel/MetamodelTest.java @@ -3632,7 +3632,7 @@ public void testManagedType_getMap_Type_param_Method() { expectedIAExceptionThrown = false; MapAttribute anAttribute = entityManufacturer_.getMap("hardwareDesignersMap", Integer.class, HardwareDesigner.class); - // verify the default key type is the not the Map key - rather that is is the managedType PK + // verify the default key type is not the Map key - rather that is the managedType PK Class keyJavaType = anAttribute.getKeyJavaType(); //@OneToMany(cascade=ALL, mappedBy="mappedEmployer") //private Map hardwareDesignersMap;// = new HashMap(); diff --git a/jpa/org.eclipse.persistence.jpa.modelgen/src/main/java/org/eclipse/persistence/internal/jpa/modelgen/objects/PersistenceXMLMappings.java b/jpa/org.eclipse.persistence.jpa.modelgen/src/main/java/org/eclipse/persistence/internal/jpa/modelgen/objects/PersistenceXMLMappings.java index fc5a89a7d72..7c49a0f055e 100644 --- a/jpa/org.eclipse.persistence.jpa.modelgen/src/main/java/org/eclipse/persistence/internal/jpa/modelgen/objects/PersistenceXMLMappings.java +++ b/jpa/org.eclipse.persistence.jpa.modelgen/src/main/java/org/eclipse/persistence/internal/jpa/modelgen/objects/PersistenceXMLMappings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -29,8 +29,10 @@ import org.eclipse.persistence.sessions.Project; +import java.util.ArrayList; + /** - * A mapping project used to read JPA 2.0 metadata (persistence.xml and its + * A mapping project used to read JPA metadata (persistence.xml and its * persistence units) through OX mappings. * * @author Guy Pelletier, Doug Clarke @@ -81,11 +83,13 @@ private static XMLDescriptor buildPUInfoDescriptor(NamespaceResolver resolver) { XMLCompositeDirectCollectionMapping classesMapping = new XMLCompositeDirectCollectionMapping(); classesMapping.setAttributeName("managedClassNames"); classesMapping.setXPath("class/text()"); + classesMapping.useCollectionClass(ArrayList.class); descriptor.addMapping(classesMapping); XMLCompositeDirectCollectionMapping mappingFilesMapping = new XMLCompositeDirectCollectionMapping(); mappingFilesMapping.setAttributeName("mappingFiles"); mappingFilesMapping.setXPath("mapping-file/text()"); + mappingFilesMapping.useCollectionClass(ArrayList.class); descriptor.addMapping(mappingFilesMapping); XMLCompositeCollectionMapping persistenceUnitPropertiesMapping = new XMLCompositeCollectionMapping(); @@ -94,6 +98,7 @@ private static XMLDescriptor buildPUInfoDescriptor(NamespaceResolver resolver) { persistenceUnitPropertiesMapping.setSetMethodName("setPersistenceUnitProperties"); persistenceUnitPropertiesMapping.setReferenceClass(SEPersistenceUnitProperty.class); persistenceUnitPropertiesMapping.setXPath("properties/property"); + persistenceUnitPropertiesMapping.useCollectionClass(ArrayList.class); descriptor.addMapping(persistenceUnitPropertiesMapping); return descriptor; diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/CMP3Policy.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/CMP3Policy.java index 5a23924927b..dfe6326036b 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/CMP3Policy.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/CMP3Policy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -132,7 +132,7 @@ public CMP3Policy clone() { */ @Override public void convertClassNamesToClasses(ClassLoader classLoader){ - if(getPKClassName() != null){ + if(getPKClass() == null && getPKClassName() != null){ try{ Class aPKClass = null; if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/EntityManagerFactoryDelegate.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/EntityManagerFactoryDelegate.java index a277a3f1ebb..c78590e0463 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/EntityManagerFactoryDelegate.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/EntityManagerFactoryDelegate.java @@ -179,7 +179,7 @@ public EntityManagerFactoryDelegate(EntityManagerSetupImpl setupImpl, Map proper /** * Create a dynamic persistence unit which does not use the persistence.xml. - * Instead all configuration is driven from the provided persistence unit + * Instead, all configuration is driven from the provided persistence unit * properties and descriptors. */ public EntityManagerFactoryDelegate(String persistenceUnitName, Map properties, List descriptors, JpaEntityManagerFactory owner) { @@ -289,7 +289,7 @@ public synchronized void close() { // (a reopened emf will re-populate the same metaModel) // (a new persistence unit will generate a new metaModel) if (setupImpl != null) { - // 260511 null check so that closing a EM + // 260511 null check so that closing an EM // created from the constructor no longer throws a NPE setupImpl.undeploy(); } @@ -297,7 +297,7 @@ public synchronized void close() { } /** - * Indicates whether or not this factory is open. Returns true + * Indicates whether this factory is open. Returns true * until a call to {@link #close} is made. */ @Override @@ -689,7 +689,7 @@ public Metamodel getMetamodel() { if (!this.isOpen()) { throw new IllegalStateException(ExceptionLocalization.buildMessage("operation_on_closed_entity_manager_factory")); } - /** + /* * Login the session and initialize descriptors - if not already, subsequent calls will just return the session * 322585: Login the session on the first call to getMetamodel() or getCriteriaBuilder() * after EMF predeploy() completes. This will do a DB login that calls diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/EntityManagerSetupImpl.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/EntityManagerSetupImpl.java index 37c854d5308..df71cd8f424 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/EntityManagerSetupImpl.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/EntityManagerSetupImpl.java @@ -132,7 +132,6 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; @@ -243,9 +242,7 @@ import org.eclipse.persistence.internal.security.PrivilegedClassForName; import org.eclipse.persistence.internal.security.PrivilegedGetDeclaredField; import org.eclipse.persistence.internal.security.PrivilegedGetDeclaredFields; -import org.eclipse.persistence.internal.security.PrivilegedGetDeclaredMethod; import org.eclipse.persistence.internal.security.PrivilegedGetValueFromField; -import org.eclipse.persistence.internal.security.PrivilegedMethodInvoker; import org.eclipse.persistence.internal.security.PrivilegedNewInstanceFromClass; import org.eclipse.persistence.internal.security.SecurableObjectHolder; import org.eclipse.persistence.internal.sessions.AbstractSession; @@ -4043,22 +4040,8 @@ private static ValidationMode getValidationMode(PersistenceUnitInfo persitenceUn } //otherwise: - ValidationMode validationMode = null; // Initialize with value in persitence.xml - // Using reflection to call getValidationMode to prevent blowing up while we are running in JPA 1.0 environment - // (This would be all JavaEE5 appservers) where PersistenceUnitInfo does not implement method getValidationMode(). - try { - Method method = null; - if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) { - method = AccessController.doPrivileged(new PrivilegedGetDeclaredMethod(PersistenceUnitInfo.class, "getValidationMode", null)); - validationMode = (ValidationMode) AccessController.doPrivileged(new PrivilegedMethodInvoker(method, persitenceUnitInfo)); - } else { - method = PrivilegedAccessHelper.getDeclaredMethod(PersistenceUnitInfo.class, "getValidationMode", null); - validationMode = PrivilegedAccessHelper.invokeMethod(method, persitenceUnitInfo, null); - } - } catch (Throwable exception) { - // We are running in JavaEE5 environment. Catch and swallow any exceptions and return null. - } + ValidationMode validationMode = persitenceUnitInfo.getValidationMode(); if(validationMode == null) { // Default to AUTO as specified in JPA spec. diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/mappings/EmbeddedAccessor.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/mappings/EmbeddedAccessor.java index 4ba7edb588e..a623c4b9044 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/mappings/EmbeddedAccessor.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/mappings/EmbeddedAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -297,7 +297,7 @@ public void setConverts(List converts) { /** * INTERNAL: * Called when process the mapsId metadata. The id fields for this owning - * descriptor must have it's id fields update to those from the one to one + * descriptor must have its id fields updated to those from the one to one * accessor that maps them. We process embedded and embedded id mappings * first, so by default they get mapped and processed as they normally * would. When we go through the relationship accessors and discover a diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataClass.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataClass.java index 359e7f4eda6..e0e9f1ad955 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataClass.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataClass.java @@ -454,12 +454,12 @@ public boolean isAccessible() { * Return if this class is an array type. */ public boolean isArray() { - return (getName() != null) && (getName().charAt(0) == '['); + return getName() != null && (getName().charAt(0) == '[' || getName().contains("[]")); } /** * INTERNAL: - * Return if this is extends Collection. + * Return if this class extends Collection. */ public boolean isCollection() { return extendsInterface(Collection.class); @@ -467,7 +467,7 @@ public boolean isCollection() { /** * INTERNAL: - * Return if this is extends Enum. + * Return if this class extends Enum. */ public boolean isEnum() { return extendsClass(Enum.class); @@ -498,7 +498,7 @@ public boolean isLazy() { /** * INTERNAL: - * Return if this is extends List. + * Return if this class extends List. */ public boolean isList() { return extendsInterface(List.class); @@ -506,7 +506,7 @@ public boolean isList() { /** * INTERNAL: - * Return if this is extends Map. + * Return if this class extends Map. */ public boolean isMap() { return extendsInterface(Map.class); @@ -541,7 +541,7 @@ public boolean isSerializable() { } /** - * INTENAL: + * INTERNAL: * Return true is this class is the Serializable.class interface. */ public boolean isSerializableInterface() { diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/IdentifiableTypeImpl.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/IdentifiableTypeImpl.java index 8e4d9fbde31..94d1f512e3b 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/IdentifiableTypeImpl.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/IdentifiableTypeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -328,7 +328,7 @@ public boolean hasSingleIdAttribute() { // The following section will return false for any multiple EmbeddableId as well as multiple Ids as part of an IdClass // Note: there will always be at least 1 Id for an IdentifiableType - /** + /* * Since we are in IdentifiableType which involves only Entities and MappedSuperclasses, * we are safe to assume that there will always be an Id of some sort - we are not in * Basic, Embeddable or transient types. @@ -343,7 +343,7 @@ public boolean hasSingleIdAttribute() { if(pkFields.isEmpty()) { return false; } else { - // Optional: Verify the mapping on the each field and whether it is an IdClass + // Optional: Verify the mapping on each field and whether it is an IdClass Class pkClass = null; if(this.getDescriptor().hasCMPPolicy()) { pkClass = this.getDescriptor().getCMPPolicy().getPKClass(); @@ -351,7 +351,7 @@ public boolean hasSingleIdAttribute() { return false; } } else { - // MappedSuperclass descriptors do not have a CMP policy yet because the are not initialized + // MappedSuperclass descriptors do not have a CMP policy yet because they are not initialized return pkFields.size() < 2; } diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/ManagedTypeImpl.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/ManagedTypeImpl.java index 6cac0be80ba..7144090c4df 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/ManagedTypeImpl.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/ManagedTypeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -290,7 +290,7 @@ public CollectionAttribute getCollection(String name, Class return getDeclaredAttribute(name, false); } - /** + /* * All getDeclared*(name, *) function calls require navigation up the superclass tree * in order to determine if the member name is declared on the current managedType.

    * If the attribute is found anywhere above on the superclass tree - then throw an IAE. @@ -299,11 +299,11 @@ public CollectionAttribute getCollection(String name, Class - attribute positioning(none, current, 1st parent, Nth parent) - attribute type (right, wrong type) - attribute classification for current and parents (Entity, MappedSuperclass, embeddable?, Basic?) - UC1) Attribute is not found on current attribute (regardless of what is on its' superclasses) + UC1) Attribute is not found on current attribute (regardless of what is on its superclasses) - throw IAException UC2) Attribute is found on current attribute but is of the wrong type - throw IAException - UC3) Attribute is found on on current managedType Entity/MappedSuperclass + UC3) Attribute is found on the current managedType Entity/MappedSuperclass (but not found anywhere on the supertype hierarchy - declared above) In this case we do the reverse - keep checking only when attribute is null - return attribute @@ -910,7 +910,7 @@ public SetAttribute getSet(String name, Class elementType) /** * INTERNAL: * This function returns whether the Object class passed in can be autoboxed - * (a primitive wrapped in its' object type) or the reverse - an autoboxed object + * (a primitive wrapped in its object type) or the reverse - an autoboxed object * that wraps a primitive type). * It answers the question of whether the two classes can be considered to be essentially the same
    * This function is used by the metamodel to determine whether the @@ -930,7 +930,7 @@ private boolean isAutoboxedType(Class targetPrimitiveOrWrapperClass, Class return false; } - /** + /* * We return true for any of the following combinations. * boolean:Boolean byte:Byte short:Short char:Character int:Integer long:Long float:Float double:Double */ @@ -1144,7 +1144,7 @@ protected void initialize() { // Future: Check all is*Policy() calls for (DatabaseMapping mapping : getDescriptor().getMappings()) { AttributeImpl member = null; - /** + /* * The following section will determine the plural attribute type for each mapping on the managedType. * Special handling is required for differentiation of List and Collection * beyond their shared IndirectList ContainerPolicy, @@ -1174,7 +1174,7 @@ protected void initialize() { // Future: Check all is*Policy() calls // check mapping.attributeAcessor.attributeField.type=Collection } else if (collectionContainerPolicy.isListPolicy()) { // This seems very over complex... - /** + /* * Handle lazy Collections and Lists and the fact that both return an IndirectList policy. * We check the type on the attributeField of the attributeAccessor on the mapping */ @@ -1216,7 +1216,7 @@ protected void initialize() { // Future: Check all is*Policy() calls } else { // handle variations of missing get/set methods - only for Collection vs List if(colMapping.getAttributeAccessor() instanceof MethodAttributeAccessor) { - /** + /* * The following call will perform a getMethod call for us. * If no getMethod exists, we will secondarily check the getMethodName below. */ @@ -1226,7 +1226,7 @@ protected void initialize() { // Future: Check all is*Policy() calls } else if((aType != null) && Collection.class.isAssignableFrom(aType)) { member = new CollectionAttributeImpl(this, colMapping, true); } else { - /** + /* * In this block we have the following scenario: * 1) The access type is "field" * 2) The get method is not set on the entity @@ -1266,7 +1266,7 @@ protected void initialize() { // Future: Check all is*Policy() calls member = initializePluralAttributeTypeNotFound(this, colMapping, true); } } else { - /** + /* * Field access Handling: * If a get method name exists, we check the return type on the method directly * using reflection. @@ -1336,7 +1336,7 @@ protected void initialize() { // Future: Check all is*Policy() calls * directly on the containing java class associated with this managedType. */ protected Class getTypeClassFromAttributeOrMethodLevelAccessor(DatabaseMapping mapping) { - /** + /* * In this block we have the following scenario: * 1) The access type is "method" or "field" * 1a) The get method is set on the entity (method access) @@ -1378,7 +1378,7 @@ protected Class getTypeClassFromAttributeOrMethodLevelAccessor(DatabaseMappin } // 4) If method level access - perform a getDeclaredMethod call - /** + /* * Field access Handling: * If a get method name exists, we check the return type on the method directly * using reflection. diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/MapAttributeImpl.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/MapAttributeImpl.java index 81ec66950ad..f5455939ac0 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/MapAttributeImpl.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/MapAttributeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -94,7 +94,7 @@ protected MapAttributeImpl(ManagedTypeImpl managedType, CollectionMapping map MapKeyMapping keyMapping = null; Object policyKeyType = null; - /** + /* * Note: the (at) sign for annotations has been replaced by the & sign for javadoc processing. * * We have the following policy structure and behavior @@ -155,7 +155,7 @@ Use AttributeClassification (since keyMapping.attributeAccessor.attributeClass = keyMapping = ((MappedKeyMapContainerPolicy)policy).getKeyMapping(); policyKeyType = keyMapping.getMapKeyTargetType(); } else { - /** + /* * Assume we have a MapContainerPolicy general superclass with a lazy-loaded keyType * or a DirectMapContainerPolicy using a &BasicMap * See UC2, UC4, UC8, UC13 (unidirectional ManyToOne becomes ManyToMany) @@ -167,7 +167,7 @@ Use AttributeClassification (since keyMapping.attributeAccessor.attributeClass = } } - /** + /* * Step 2: We determine the java class from the policyKeyType (class or ClassDecriptor) * We also perform alternate keyType lookup for the case where * the name attribute is not specified in a MapKey annotation where diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/MetamodelImpl.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/MetamodelImpl.java index 2e07032b34c..0dd848a0100 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/MetamodelImpl.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/MetamodelImpl.java @@ -109,7 +109,7 @@ public class MetamodelImpl implements Metamodel, Serializable { /** maintains initialization state to avoid extra work in calls to initialize **/ private boolean isInitialized = false; - /** Default elementType Class when we the type cannot be determined for unsupported mappings such as Transformation and VariableOneToOne */ + /** Default elementType Class when the type cannot be determined for unsupported mappings such as Transformation and VariableOneToOne */ public static final Class DEFAULT_ELEMENT_TYPE_FOR_UNSUPPORTED_MAPPINGS = Object.class; public MetamodelImpl(AbstractSession session) { @@ -337,7 +337,7 @@ public Map> getTypes() { * Referenced by ManagedTypeImpl.create() */ protected boolean hasMappedSuperclass(String qualifiedClassNameKeyString) { - /** + /* * This function is used before the metamodel has populated its Set of mappedSuperclasses - * therefore we go directly to the descriptor source. * Normally this functionality would be placed on the (core) Project class, however @@ -417,7 +417,7 @@ private void preInitialize(){ * * Initialize the JPA metamodel that wraps the EclipseLink JPA metadata created descriptors.
    * Note: Since the types Map is lazy-loaded with key:value pairs - the designer and especially the user - * must realized that a particular BasicType may not be in the Map until it is referenced. + * must realize that a particular BasicType may not be in the Map until it is referenced. * * Also note that a transient superclass (non-entity, non-mappedSuperclass) * exists as a BasicType (it has no attributes), and that any inheriting Entity either @@ -435,14 +435,14 @@ public void initialize(ClassLoader classLoader) { // Assign all superType fields on all IdentifiableTypes (only after all managedType objects have been created) for(ManagedTypeImpl potentialIdentifiableType : managedTypes.values()) { Class aClass = potentialIdentifiableType.getJavaType(classLoader); - /** + /* * The superclass for top-level types is Object - however we set [null] as the supertype for root types. * 1) We are constrained by the fact that the spec requires that a superType be an IdentifiableType. - * Since [Object] is not an Entity or MappedSuperclass - it fails this criteria - as it would be a BasicType + * Since [Object] is not an Entity or MappedSuperclass - it fails these criteria - as it would be a BasicType * because it has no @Entity or @MappedSuperclass annotation.

    * 2) Another object space reasoning issue behind this is to separate the Java and Metamodel object spaces. * In Java all types inherit from Object, however in the JPA Metamodel all types DO NOT inherit from a common type. - * Therefore in the metamodel top-level root types have a superType of null. + * Therefore, in the metamodel top-level root types have a superType of null. * See design issue discussion: * http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#DI_42:_20090709:_IdentifiableType.supertype_-_what_do_top-level_types_set_it_to */ @@ -472,10 +472,10 @@ public void initialize(ClassLoader classLoader) { } } - //1 - process all non-mappedSuperclass types first so we pick up attribute types + //1 - process all non-mappedSuperclass types first, so we pick up attribute types //2 - process mappedSuperclass types and lookup collection attribute types on inheriting entity types when field is not set - /** + /* * Delayed-Initialization (process all mappings) of all Managed types * (This includes all IdentifiableTypes = Entity and MappedSuperclass types). * To avoid a ConcurrentModificationException on the types map, iterate a list instead of the Map values directly. diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/PluralAttributeImpl.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/PluralAttributeImpl.java index b77aaf4a789..e165ca2d541 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/PluralAttributeImpl.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metamodel/PluralAttributeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -78,13 +78,13 @@ protected PluralAttributeImpl(ManagedTypeImpl managedType, CollectionMapping // TODO: handle AggregateCollectionMapping and verify isAbstractDirectMapping if(mapping.isDirectCollectionMapping() || mapping.isAbstractCompositeDirectCollectionMapping() || mapping.isDirectCollectionMapping()) { - /** + /* * The Map Value parameter was set during metadata processing in DirectCollectionMapping.convertClassNamesToClasses() for example. * The attributeClassification is set from the valueField.typeName String instead of the type Class because of the * way that converters shadow the type/typeName in bug# 289487 */ attributeClass = mapping.getAttributeClassification(); - /** + /* * REFACTOR * We were unable to get the type because it is not declared as a generic parameter on the method level attribute. * It may be declared on the field.