Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-dev] Eclipselink transaction details

Short description: Fix allows a LAZY specification on mappings within an embeddable.

New tests: No new tests added, extended existing inheritance model and related test file

Reviewed by: Tom Ware

SVN patch files attached.

Cheers,
Guy
Index: C:/Work/eclipse/jpa/eclipselink.jpa/.classpath
===================================================================
--- C:/Work/eclipse/jpa/eclipselink.jpa/.classpath	(revision 3580)
+++ C:/Work/eclipse/jpa/eclipselink.jpa/.classpath	(working copy)
@@ -3,5 +3,6 @@
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
	<classpathentry combineaccessrules="false" exported="true" kind="src" path="/eclipselink.core"/>
	<classpathentry excluding="**/.svn/**" kind="src" path="src"/>
+	<classpathentry kind="var" path="JAVAEE_LIB"/>
	<classpathentry kind="output" path="classes"/>
</classpath>
Index: C:/Work/eclipse/jpa/eclipselink.jpa/src/org/eclipse/persistence/jpa/JpaHelper.java
===================================================================
--- C:/Work/eclipse/jpa/eclipselink.jpa/src/org/eclipse/persistence/jpa/JpaHelper.java	(revision 3580)
+++ C:/Work/eclipse/jpa/eclipselink.jpa/src/org/eclipse/persistence/jpa/JpaHelper.java	(working copy)
@@ -23,7 +23,7 @@
* This sample illustrates the JPA helper methods that may be of use * to EclipseLink customers attempting to leverage EclipseLink specific functionality. * - * @author Doug Clarke + * @author dclarke, gpelletie */ public class JpaHelper { /** @@ -31,14 +31,8 @@ * and not in a transaction this method may incorrectly return false. * It is always more reliable to check isEclipseLink on the EMF or Query. */ - public static boolean isEclipseLink(javax.persistence.EntityManager em) { - try { - JpaEntityManager emImpl = getEntityManager(em); - } catch (IllegalArgumentException iae) { - return false; - } - - return em != null; + public static boolean isEclipseLink(javax.persistence.EntityManager em) { + return getEntityManager(em) != null; } /** Index: C:/Work/eclipse/jpa/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProject.java
===================================================================
--- C:/Work/eclipse/jpa/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProject.java	(revision 3580)
+++ C:/Work/eclipse/jpa/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProject.java	(working copy)
@@ -70,8 +70,8 @@
    // persistence unit that is represented by this project
    protected PersistenceUnitInfo m_PUInfo;

-    // names of all the entity in this PU
-    protected Collection<String> m_entityNames = new HashSet<String>();
+    // Names of all the 'weavable' classes for this project.
+    protected Collection<String> m_weavableClassNames = new HashSet<String>();

    // URL to Document object map of all the mapping files for this PU.
    // The reason for using URL instead of name is that name is not unique.
@@ -394,13 +394,6 @@
    public Node getEmbeddableNode(Class cls) {
        return m_embeddableNodes.get(cls.getName());
    }
- - /**
-     * INTERNAL:
-     */
-    public Collection<String> getEntityNames() {
-        return Collections.unmodifiableCollection(m_entityNames);
-    }

    /**
     * INTERNAL:
@@ -496,7 +489,16 @@
/**
     * INTERNAL:
+ * Returns all those classes in this project that are available for + * weaving. This list currently includes entity and embeddables classes.
     */
+    public Collection<String> getWeavableClassNames() {
+        return Collections.unmodifiableCollection(m_weavableClassNames);
+    }
+ + /**
+     * INTERNAL:
+     */
    public boolean hasConflictingSequenceGenerator(MetadataSequenceGenerator sequenceGenerator) {
        if (hasSequenceGenerator(sequenceGenerator.getName())) {
            return ! getSequenceGenerator(sequenceGenerator.getName()).equals(sequenceGenerator);
@@ -944,14 +946,6 @@
    /**
     * INTERNAL:
     */
-    public void setEntityNames(Collection<String> entityNames) {
-        m_entityNames.clear();
-        m_entityNames.addAll(entityNames);
-    }
- - /**
-     * INTERNAL:
-     */
    public void setMappingFiles(Map<URL, Document> mappingFiles) {
        m_mappingFiles.clear();
        m_mappingFiles.putAll(mappingFiles);
@@ -964,5 +958,13 @@
    public void setPersistenceUnit(MetadataPersistenceUnit persistenceUnit) {
        m_persistenceUnit = persistenceUnit;
    }
+ + /**
+     * INTERNAL:
+     */
+    public void setWeavableClassNames(Collection<String> weavableClassNames) {
+        m_weavableClassNames.clear();
+        m_weavableClassNames.addAll(weavableClassNames);
+    }
}

Index: C:/Work/eclipse/jpa/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProcessor.java
===================================================================
--- C:/Work/eclipse/jpa/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProcessor.java	(revision 3580)
+++ C:/Work/eclipse/jpa/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProcessor.java	(working copy)
@@ -102,7 +102,7 @@
            m_project.addDescriptor(new MetadataDescriptor(entity));
            entityNames.add(entity.getName());
        }
-        m_project.setEntityNames(entityNames);
+        m_project.setWeavableClassNames(entityNames);
        m_logger = new MetadataLogger(session);
    }
@@ -138,29 +138,6 @@
    }
/**
-     * Return a set of class names for each entity found in the xml
-     * descriptor instance document.
-     */
-    private static Set<String> buildEntityClassSetFromXMLDocument(Document document, String fileName, ClassLoader loader, boolean includeMappedSuperclasses, boolean includeEmbedables) {
-        XMLHelper helper = new XMLHelper(document, fileName, loader);
- - // Process the package node.
-        String defaultPkg = helper.getNodeValue(new String[] {XMLConstants.ENTITY_MAPPINGS, XMLConstants.PACKAGE, XMLConstants.TEXT});
-
-        // Handle entities only. Mapped superclasses and embeddables are
-        // discovered and processed separately.
-        HashSet<String> classSet = new HashSet<String>();
-        classSet.addAll(buildEntityClassSetForNodeList(helper, XMLConstants.ENTITY, defaultPkg));
-        if (includeEmbedables) {
-            classSet.addAll(buildEntityClassSetForNodeList(helper, XMLConstants.EMBEDDABLE, defaultPkg));
-        }
-        if (includeMappedSuperclasses){
-            classSet.addAll(buildEntityClassSetForNodeList(helper, XMLConstants.MAPPED_SUPERCLASS, defaultPkg));
-        }
-        return classSet;
-    }
- - /**
     * INTERNAL:
* The class name of each node in the node list will be added to the * provided collection.
@@ -178,6 +155,40 @@
        return classNames;
    }
+ /**
+     * INTERNAL:
+ * Return a set of class names for each entity, embeddable and mapped + * superclass found in the list of xml descriptor instance documents to be + * processed by the MetadataProcessor.
+     */
+    public Set<String> buildPersistenceUnitClassSetFromXMLDocuments() {
+        HashSet<String> classSet = new HashSet<String>();
+ + for (Map.Entry<URL, Document> urlToDoc : m_project.getMappingFiles().entrySet()) {
+            XMLHelper helper = new XMLHelper(urlToDoc.getValue(), urlToDoc.getKey().getFile(), m_loader);
+ + // Process the package node.
+            String defaultPkg = helper.getNodeValue(new String[] {XMLConstants.ENTITY_MAPPINGS, XMLConstants.PACKAGE, XMLConstants.TEXT});
+
+            // Handle entities only unless otherwise specified to.
+            classSet.addAll(buildEntityClassSetForNodeList(helper, XMLConstants.ENTITY, defaultPkg));
+            classSet.addAll(buildEntityClassSetForNodeList(helper, XMLConstants.EMBEDDABLE, defaultPkg));
+            classSet.addAll(buildEntityClassSetForNodeList(helper, XMLConstants.MAPPED_SUPERCLASS, defaultPkg));
+        }
+ + return classSet;
+    }
+ + /**
+     * This method frees up resources acquired by this object.
+     */
+    public void cleanup() {
+        m_project.cleanup();
+        m_loader = null;
+        m_project = null;
+        m_session = null;
+    }
+ /** * INTERNAL:
	 * Return the logger used by the processor.
@@ -189,17 +200,70 @@
    /**
     * INTERNAL:
     */
-     public MetadataProject getProject() {
-         return m_project;
-     }
- + public MetadataProject getProject() {
+    	return m_project;
+    }
+
+    /**
+     * INTERNAL:
+ * + * Return a list of instantiated StructConverter objects that were defined in the
+     * metadata of this project.
+ * + * These StructConverters can be added to the Session + * + * @param loader + * @return List<StructConverter> + */
+    public List<StructConverter> getStructConverters(ClassLoader loader) {
+        List<StructConverter> structConverters = new ArrayList<StructConverter>();
+        for (MetadataStructConverter converter: m_project.getStructConverters().values()) {
+            StructConverter structConverter = (StructConverter) MetadataHelper.getClassInstance(converter.getConverterClassName(), loader);
+            structConverters.add(structConverter);
+        }
+        return structConverters;
+    }
+ /** * INTERNAL:
	 * Return the validator used by the processor.
	 */
-	public MetadataValidator getValidator() {
-        return m_validator;
+    public MetadataValidator getValidator() {
+    	return m_validator;
    }
+ + /**
+     *  Handle an exception that occured while processing ORM xml
+     */
+    private void handleORMException(RuntimeException e, String mf, boolean throwException){
+        if (m_session == null) {
+    	    // Metadata processor is mainly used with a session.
+    		// Java SE bootstraping uses some functions such as ORM processing without
+    		// a session.  In these cases, it is impossible to get the
+    		// session to properly handle the exception.  As a result we
+    		// log an error.  The same code will be called later in the bootstrapping
+    		// code and the error will be handled then.
+    		AbstractSessionLog.getLog().log(SessionLog.CONFIG, EntityManagerSetupImpl.ERROR_LOADING_XML_FILE, new Object[] {mf, e});
+    	} else if (!throwException) {
+    		// fail quietly
+    		m_session.log(SessionLog.CONFIG, SessionLog.EJB_OR_METADATA, EntityManagerSetupImpl.ERROR_LOADING_XML_FILE, new Object[] {mf, e});
+    	} else {
+    		// fail loudly
+    		m_session.handleException(e);
+    	}
+    }
+ + /**
+     * Log an untranslated message to the TopLink log at FINER level.
+     * @param msg message to be logged
+     */
+    private void logMessage(String msg) {
+        if (m_session == null) {
+    	    AbstractSessionLog.getLog().log(SessionLog.FINER, msg);
+        } else {
+        	m_session.logMessage(msg);
+    	}
+    }
	
    /**
     * INTERNAL:
@@ -245,33 +309,140 @@
            try {
                customizer.customize(descriptor.getClassDescriptor());
            } catch (Exception e) {
- // WIP + // fail silently ...
            }
        }
    }
+
+    /**
+     * Process the xml and fill in the project. Process the entity-mappings
+     * information then process the entities.
+     */
+    private void processMappingFile(Document document, String fileName) {
+        if (m_project.hasDescriptors()) {
+            XMLHelper helper = new XMLHelper(document, fileName, m_loader);
+
+            // Process the entity mappings ... this is a crude way of doing
+            // things ... but hey ... the clock is ticking ...
+            MetadataDescriptor desc = m_project.getDescriptors().iterator().next();
+            XMLClassAccessor dummyAccessor = new XMLClassAccessor(new MetadataClass(desc.getJavaClass()), null, helper, this, desc);
+            dummyAccessor.processEntityMappings();
+
+            // Process the entity nodes for this xml document.
+            NodeList entityNodes = helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.ENTITY);
+
+            if (entityNodes != null) {
+                for (int i = 0; i < entityNodes.getLength(); i++) {
+                    Node entityNode = entityNodes.item(i);
+                    Class entityClass = helper.getClassForNode(entityNode);
+                    MetadataDescriptor descriptor = m_project.getDescriptor(entityClass);
+
+                    // Process all descriptors that are in our project.
+                    ClassAccessor accessor = descriptor.getClassAccessor();
+
+                    // If there is no accessor on this descriptor then it has not
+                    // been processed yet. Create one and process it.
+                    if (accessor == null) {
+                        accessor = new XMLClassAccessor(new MetadataClass(descriptor.getJavaClass()), entityNode, helper, this, descriptor);
+                        descriptor.setClassAccessor(accessor);
+                        accessor.process();
+                    }
+                }
+            }
+        } else {
+            // There are no classes to process ...
+        }
+    }
/**
     * INTERNAL:
+     * Process metadata found in all the mapping files for this PU.
+     * @see #processMappingFile(org.w3c.dom.Document, String)
+     */
+    public void processMappingFiles() {
+        for (Map.Entry<URL, Document> urlToDocPair : m_project.getMappingFiles().entrySet()) {
+            processMappingFile(urlToDocPair.getValue(), urlToDocPair.getKey().getFile());
+        }
+    }
+ + /**
+     * INTERNAL:
+ * This method is responsible for discovering all the entity classes for + * this PU and adding corresponding MetadataDescriptor in the + * MetadataProject. * - * Return a list of instantiated StructConverter objects that were defined in the
-     * metadata of this project.
+ * This method will also gather all the weavable classes for this PU. + * Currently, entity and embeddable classes are weavable. * - * These StructConverters can be added to the Session - * - * @param loader - * @return List<StructConverter> + * DO NOT CALL THIS METHOD MORE THAN ONCE PER PERSISTENCE UNIT.
     */
-    public List<StructConverter> getStructConverters(ClassLoader loader) {
-        List<StructConverter> structConverters = new ArrayList<StructConverter>();
-        for (MetadataStructConverter converter: m_project.getStructConverters().values()) {
-            StructConverter structConverter = (StructConverter) MetadataHelper.getClassInstance(converter.getConverterClassName(), loader);
-            structConverters.add(structConverter);
+    public void processPersistenceUnitClasses() {
+        Set<String> entityClassNames = new HashSet<String>();
+        Set<String> weavableClassNames = new HashSet<String>();
+ + // Iterate through the classes are defined with annotations.
+        PersistenceUnitInfo puInfo = m_project.getPUInfo();
+
+        processPersistenceUnitClasses(puInfo.getManagedClassNames(), entityClassNames, weavableClassNames);
+
+        for (URL url : puInfo.getJarFileUrls()) {
+            processPersistenceUnitClasses(PersistenceUnitProcessor.getClassNamesFromURL(url), entityClassNames, weavableClassNames);
        }
-        return structConverters;
+
+        if (! puInfo.excludeUnlistedClasses()) {
+            processPersistenceUnitClasses(PersistenceUnitProcessor.getClassNamesFromURL(puInfo.getPersistenceUnitRootUrl()), entityClassNames, weavableClassNames);
+        }
+
+        // Iterate though the classes that are defined in XML.
+        for (Map.Entry<URL, Document> urlToDoc : m_project.getMappingFiles().entrySet()) {
+            //classSet.addAll(buildEntityClassSetFromXMLDocument(urlToDoc.getValue(), urlToDoc.getKey().getFile(), m_loader, includeMappedSuperclasses, includeEmbeddables));
+            XMLHelper helper = new XMLHelper(urlToDoc.getValue(), urlToDoc.getKey().getFile(), m_loader);
+ + // Process the package node.
+            String defaultPkg = helper.getNodeValue(new String[] {XMLConstants.ENTITY_MAPPINGS, XMLConstants.PACKAGE, XMLConstants.TEXT});
+
+            // Add the entities to the entity and weavable class list.
+            Set<String> xmlEntityClassNames = buildEntityClassSetForNodeList(helper, XMLConstants.ENTITY, defaultPkg);
+            entityClassNames.addAll(xmlEntityClassNames);
+            weavableClassNames.addAll(xmlEntityClassNames);
+ + // Add the embeddables to the weavable class list. + weavableClassNames.addAll(buildEntityClassSetForNodeList(helper, XMLConstants.EMBEDDABLE, defaultPkg)); + }
+
+        // Set the weavable classes on the project.
+        m_project.setWeavableClassNames(weavableClassNames);
+
+        // Add a metadata descriptor to the project for every entity class.
+        // Any persistence unit metadata/defaults will be applied
+        for (String className : entityClassNames) {
+            try {
+                m_project.addDescriptor(new MetadataDescriptor(m_loader.loadClass(className)));
+            } catch (ClassNotFoundException e) {
+                AbstractSessionLog.getLog().log(SessionLog.WARNING, "exception_loading_entity_class", className, e);
+            }
+        }
    }
/**
     * INTERNAL:
+     * Process the given persistence unit class name.
+     */
+    private void processPersistenceUnitClasses(Collection<String> classNames, Set<String> entityClassNames, Set<String> weavableClassNames) {
+        for (String className: classNames) {
+            Class candidateClass = PersistenceUnitProcessor.loadClass(className, m_loader, true);
+ + if (PersistenceUnitProcessor.isEntity(candidateClass)) {
+                entityClassNames.add(className);
+                weavableClassNames.add(className);
+            } else if (PersistenceUnitProcessor.isEmbeddable(candidateClass)) {
+                weavableClassNames.add(className);
+            }
+        }
+    }
+ + /**
+     * INTERNAL:
* Process persistence unit metadata and defaults, and apply them to each * entity in the collection. Any conflicts in elements defined in multiple * documents will cause an exception to be thrown. The first instance @@ -281,7 +452,7 @@ * found will be added to a list in the order that they are read from the * instance document(s). */
-     public void processPersistenceUnitMetadata() {
+    public void processPersistenceUnitMetadata() {
        // For each orm xml instance document, process persistence unit
        // metadata/defaults and mapped superclasses.
        for (Map.Entry<URL, Document> mfDocPair : m_project.getMappingFiles().entrySet()) {
@@ -355,13 +526,33 @@
        }
    }
- /**
-     * INTERNAL:
-	 * Use this method to set the correct class loader that should be used
-     * during processing.
-	 */
-	public void setClassLoader(ClassLoader loader) {
-        m_loader = loader;
+    private Map<URL, Document> readExplicitlySpecifiedMappingFiles(boolean throwExceptionOnFail) {
+        Map<URL, Document> list = new HashMap<URL, Document>();
+        final PersistenceUnitInfo puInfo = m_project.getPUInfo();
+        for (String mf : puInfo.getMappingFileNames()) {
+            try {
+                Enumeration<URL> mfURLs = m_loader.getResources(mf);
+                if (mfURLs.hasMoreElements()) {
+                    URL nextURL = mfURLs.nextElement();
+                    if (mfURLs.hasMoreElements()) {
+                        handleORMException(ValidationException.nonUniqueMappingFileName(puInfo.getPersistenceUnitName(), mf), mf, throwExceptionOnFail);
+                    }
+                    InputStream stream = null;
+                    stream = nextURL.openStream();
+                    Document document = XMLHelper.parseDocument(stream, nextURL.getFile(), m_loader);
+                    list.put(nextURL, document);
+                    try {
+                        stream.close();
+                    } catch (IOException e) {}
+                } else {
+                    handleORMException(ValidationException.mappingFileNotFound(puInfo.getPersistenceUnitName(), mf), mf, throwExceptionOnFail);
+                }
+            } catch (IOException e) {
+                handleORMException(PersistenceUnitLoadingException.exceptionLoadingORMXML(mf, e), mf, throwExceptionOnFail);
+            }
+        }
+
+        return list;
    }

    /**
@@ -417,200 +608,12 @@
        return list;
    }

-    private Map<URL, Document> readExplicitlySpecifiedMappingFiles(
-            boolean throwExceptionOnFail) {
-        Map<URL, Document> list = new HashMap<URL, Document>();
-        final PersistenceUnitInfo puInfo = m_project.getPUInfo();
-        for (String mf : puInfo.getMappingFileNames()) {
-            try {
-                Enumeration<URL> mfURLs = m_loader.getResources(mf);
-                if (mfURLs.hasMoreElements()) {
-                    URL nextURL = mfURLs.nextElement();
-                    if(mfURLs.hasMoreElements()) {
-                        handleORMException(ValidationException.nonUniqueMappingFileName(puInfo.getPersistenceUnitName(), mf), mf, throwExceptionOnFail);
-                    }
-                    InputStream stream = null;
-                    stream = nextURL.openStream();
-                    Document document = XMLHelper.parseDocument(stream, nextURL.getFile(), m_loader);
-                    list.put(nextURL, document);
-                    try{
-                        stream.close();
-                    } catch (IOException e) {}
-                } else {
-                    handleORMException(ValidationException.mappingFileNotFound(puInfo.getPersistenceUnitName(), mf), mf, throwExceptionOnFail);
-                }
-            } catch (IOException e) {
-                handleORMException(
-                        PersistenceUnitLoadingException.exceptionLoadingORMXML(mf, e),
-                        mf, throwExceptionOnFail);
-            }
-        }
-        return list;
-    }
-
    /**
-     *  Handle an exception that occured while processing ORM xml
-     */
-    private void handleORMException(
-            RuntimeException e,
-            String mf,
-            boolean throwException){
-        if (m_session == null){
-            // Metadata processor is mainly used with a session.
-            // Java SE bootstraping uses some functions such as ORM processing without
-            // a session.  In these cases, it is impossible to get the
-            // session to properly handle the exception.  As a result we
-            // log an error.  The same code will be called later in the bootstrapping
-            // code and the error will be handled then.
-            AbstractSessionLog.getLog().log(SessionLog.CONFIG,
-                    EntityManagerSetupImpl.ERROR_LOADING_XML_FILE,
-                    new Object[] {mf, e});
-        } else if (!throwException) {
-            // fail quietly
-            m_session.log(SessionLog.CONFIG,
-                    SessionLog.EJB_OR_METADATA,
-                    EntityManagerSetupImpl.ERROR_LOADING_XML_FILE,
-                    new Object[] {mf, e});
-        } else {
-            // fail loudly
-            m_session.handleException(e);
-        }
+     * INTERNAL:
+	 * Use this method to set the correct class loader that should be used
+     * during processing.
+	 */
+	public void setClassLoader(ClassLoader loader) {
+        m_loader = loader;
    }
-
-    /**
-     * This method is responsible for discovering all the entity and embedable classes
-     * for this PU and adding corresponding MetadataDescriptor in the
-     * MetadataProject. Don't call this method more than once.
-     */
-    public void buildEntityList() {
-        Set<String> entityAndEmbedableClassNames = buildEntityClassSetFromAnnotations(true);
-        Set<String> entityClassNames = buildEntityClassSetFromAnnotations(false);
-
-        // Append the list of entity classes that are defined in XML.
-        entityAndEmbedableClassNames.addAll(buildEntityClassSetFromXMLDocuments(false, true));
-        entityClassNames.addAll(buildEntityClassSetFromXMLDocuments(false, false));
-
-        m_project.setEntityNames(entityAndEmbedableClassNames);
-
-        // Add a metadata descriptor to the project for every entity class.
-        // Any persistence unit metadata/defaults will be applied.
-        // Must not process embedables as the are processed differently.
-        for (String className : entityClassNames) {
-            try {
-                m_project.addDescriptor(new MetadataDescriptor(m_loader.loadClass(className)));
-            } catch (ClassNotFoundException exception) {
-                AbstractSessionLog.getLog().log(SessionLog.WARNING, "exception_loading_entity_class", className, exception);
-            }
-        }
-    }
-
-    /**
-     * Return a set of class names that are annotated as either @Entity
-     * from the base URL of this PersistenceUnit
-     */
-    private Set<String> buildEntityClassSetFromAnnotations(boolean includeEmbedables) {
-        Set<String> set = new HashSet<String>();
-        PersistenceUnitInfo puInfo = m_project.getPUInfo();
-
-        for (String className : puInfo.getManagedClassNames()) {
-            if (PersistenceUnitProcessor.isEntity(className, m_loader, true, includeEmbedables)) {
-                set.add(className);
-            }
-        }
-
-        for (URL url : puInfo.getJarFileUrls()) {
-            set.addAll(PersistenceUnitProcessor.getEntityClassNamesFromURL(url, m_loader, includeEmbedables));
-        }
-
-        if (!puInfo.excludeUnlistedClasses()){
-            set.addAll(PersistenceUnitProcessor.getEntityClassNamesFromURL(puInfo.getPersistenceUnitRootUrl(), m_loader, includeEmbedables));
-        }
-        return set;
-    }
-
-    /**
-     * Return a set of class names for each entity found in the
-     * list of xml descriptor instance documents to be processed by the
-     * MetadataProcessor.
-     */
-    public Set<String> buildEntityClassSetFromXMLDocuments(boolean includeMappedSuperClasses, boolean includeEmbedables) {
-        HashSet<String> classSet = new HashSet<String>();
-        for (Map.Entry<URL, Document> urlToDoc :  m_project.getMappingFiles().entrySet()) {
-            classSet.addAll(buildEntityClassSetFromXMLDocument(
-                    urlToDoc.getValue(), urlToDoc.getKey().getFile(), m_loader, includeMappedSuperClasses, includeEmbedables));
-        }
-        return classSet;
-    }
-
-    /**
-     * Process metadata found in all the mapping files for this PU.
-     * @see #processMappingFile(org.w3c.dom.Document, String)
-     */
-    public void processMappingFiles() {
-        for (Map.Entry<URL, Document> urlToDocPair : m_project.getMappingFiles().entrySet()) {
-            processMappingFile(urlToDocPair.getValue(), urlToDocPair.getKey().getFile());
-        }
-    }
-
-    /**
-     * Process the xml and fill in the project. Process the entity-mappings
-     * information then process the entities.
-     */
-    private void processMappingFile(Document document, String fileName) {
-        if (m_project.hasDescriptors()) {
-            XMLHelper helper = new XMLHelper(document, fileName, m_loader);
-
-            // Process the entity mappings ... this is a crude way of doing
-            // things ... but hey ... the clock is ticking ...
-            MetadataDescriptor desc = m_project.getDescriptors().iterator().next();
-            XMLClassAccessor dummyAccessor = new XMLClassAccessor(new MetadataClass(desc.getJavaClass()), null, helper, this, desc);
-            dummyAccessor.processEntityMappings();
-
-            // Process the entity nodes for this xml document.
-            NodeList entityNodes = helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.ENTITY);
-
-            if (entityNodes != null) {
-                for (int i = 0; i < entityNodes.getLength(); i++) {
-                    Node entityNode = entityNodes.item(i);
-                    Class entityClass = helper.getClassForNode(entityNode);
-                    MetadataDescriptor descriptor = m_project.getDescriptor(entityClass);
-
-                    // Process all descriptors that are in our project.
-                    ClassAccessor accessor = descriptor.getClassAccessor();
-
-                    // If there is no accessor on this descriptor then it has not
-                    // been processed yet. Create one and process it.
-                    if (accessor == null) {
-                        accessor = new XMLClassAccessor(new MetadataClass(descriptor.getJavaClass()), entityNode, helper, this, descriptor);
-                        descriptor.setClassAccessor(accessor);
-                        accessor.process();
-                    }
-                }
-            }
-        } else {
-            // WIP - log a warning that we have no entities to process ...
-        }
-    }
-
-    /**
-     * This method frees up resources acquired by this object.
-     */
-    public void cleanup() {
-        m_project.cleanup();
-        m_loader = null;
-        m_project = null;
-        m_session = null;
-    }
-
-    /**
-     * Log an untranslated message to the TopLink log at FINER level.
-     * @param msg message to be logged
-     */
-    private void logMessage(String msg) {
-        if (m_session == null){
-            AbstractSessionLog.getLog().log(SessionLog.FINER, msg);
-        } else {
-            m_session.logMessage(msg);
-        }
-    }
}
Index: C:/Work/eclipse/jpa/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/deployment/PersistenceUnitProcessor.java
===================================================================
--- C:/Work/eclipse/jpa/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/deployment/PersistenceUnitProcessor.java	(revision 3580)
+++ C:/Work/eclipse/jpa/eclipselink.jpa/src/org/eclipse/persistence/internal/jpa/deployment/PersistenceUnitProcessor.java	(working copy)
@@ -44,103 +44,16 @@
/**
 * INTERNAL:
 * Utility Class that deals with persistence archives for EJB 3.0
- * Provides functions like searching for persistence archives, processing persistence.xml
- * and searching for Entities in a Persistence archive
+ * Provides functions like searching for persistence archives, processing + * persistence.xml and searching for Entities in a Persistence archive
 */
public class PersistenceUnitProcessor  {

    /**
-     * Get a list of persitence units from the file or directory at the given url
-     * PersistenceUnits are built based on the presence of persistence.xml in a META-INF directory
-     * at the base of the URL
-     * @param archive The url of a jar file or directory to check.
+ * Entries in a zip file are directory entries using slashes to separate + * them. Build a class name using '.' instead of slash and removing the + * '.class' extension.
     */
-    public static List<SEPersistenceUnitInfo> getPersistenceUnits(Archive archive, ClassLoader loader){
-        return processPersistenceArchive(archive, loader);
-    }
-
-    /**
-     * Go through the jar file for this PeristeneUnitProcessor and process any XML provided in it
-     */
-    public static List<SEPersistenceUnitInfo> processPersistenceArchive(Archive archive, ClassLoader loader){
-        URL puRootURL = archive.getRootURL();
-        try {
-            InputStream pxmlStream = archive.getEntry("META-INF/persistence.xml"); // NOI18N
-            return processPersistenceXML(puRootURL, pxmlStream, loader);
-        } catch (IOException e) {
-            throw PersistenceUnitLoadingException.exceptionLoadingFromUrl(puRootURL.toString(), e);
-        }
-    }
-
-    /**
-     * Build a persistence.xml file into a SEPersistenceUnitInfo object.
-     */
-    private static List<SEPersistenceUnitInfo> processPersistenceXML(URL baseURL, InputStream input, ClassLoader loader){
-        SAXParserFactory spf = SAXParserFactory.newInstance();
-        spf.setNamespaceAware(true);
-        spf.setValidating(true);
- - XMLReader xmlReader = null;
-        SAXParser sp = null;
-        XMLExceptionHandler xmlErrorHandler = new XMLExceptionHandler();
-
-        // create a SAX parser
-        try {
-            sp = spf.newSAXParser();
-	        sp.setProperty(XMLConstants.SCHEMA_LANGUAGE, XMLConstants.XML_SCHEMA);
-	    } catch (javax.xml.parsers.ParserConfigurationException exc){
-	    	throw XMLParseException.exceptionCreatingSAXParser(baseURL, exc);
-	    } catch (org.xml.sax.SAXException exc){
-	    	throw XMLParseException.exceptionCreatingSAXParser(baseURL, exc);
-	    }
- - // create an XMLReader
-	    try {
-            xmlReader = sp.getXMLReader();
-	        xmlReader.setErrorHandler(xmlErrorHandler);
-        } catch (org.xml.sax.SAXException exc){
-        	throw XMLParseException.exceptionCreatingXMLReader(baseURL, exc);
-        }
- - // attempt to load the schema from the classpath
-        URL schemaURL = loader.getResource(XMLConstants.PERSISTENCE_SCHEMA_NAME);
-        if (schemaURL != null) {
-            try {
-            	sp.setProperty(XMLConstants.JAXP_SCHEMA_SOURCE, schemaURL.toString());
-            } catch (org.xml.sax.SAXException exc){
-            	throw XMLParseException.exceptionSettingSchemaSource(baseURL, schemaURL, exc);
-            }
-        }
-        PersistenceContentHandler myContentHandler = new PersistenceContentHandler();
-        xmlReader.setContentHandler(myContentHandler);
-
-        InputSource inputSource = new InputSource(input);
-        try{
-            xmlReader.parse(inputSource);
-        } catch (IOException exc){
-            throw PersistenceUnitLoadingException.exceptionProcessingPersistenceXML(baseURL, exc);
-        } catch (org.xml.sax.SAXException exc){
-        	// XMLErrorHandler will handle SAX exceptions
-        }
- - // handle any parse exceptions
-        XMLException xmlError = xmlErrorHandler.getXMLException();
-        if (xmlError != null) {
-            throw PersistenceUnitLoadingException.exceptionProcessingPersistenceXML(baseURL, xmlError);
-        }
-
-        Iterator<SEPersistenceUnitInfo> persistenceInfos = myContentHandler.getPersistenceUnits().iterator();
-        while (persistenceInfos.hasNext()){
-            SEPersistenceUnitInfo info = persistenceInfos.next();
- info.setPersistenceUnitRootUrl(baseURL); - }
-        return myContentHandler.getPersistenceUnits();
-    }
-
-    /**
-     * Entries in a zip file are directory entries using slashes to separate them.
-     * Build a class name using '.' instead of slash and removing the '.class' extension.
-     */
    public static String buildClassNameFromEntryString(String classEntryString){
        String classNameForLoader = classEntryString;
        if (classEntryString.endsWith(".class")){ // NOI18N
@@ -149,9 +62,9 @@
        }
        return classNameForLoader;
    }
-
+ /**
-     * Build a set that contains all the class names at a URL
+     * Build a set that contains all the class names at a URL.
     * @return a Set of class name strings
     */
    public static Set<String> buildClassSet(PersistenceUnitInfo persistenceUnitInfo, ClassLoader loader){
@@ -167,9 +80,33 @@
set.addAll(buildPersistentClassSetFromXMLDocuments(persistenceUnitInfo, loader)); return set;
    }
+ + /** + * Create a list of the entities that will be deployed. This list is built + * from the information provided in the PersistenceUnitInfo argument. + * The list contains Classes specified in the PersistenceUnitInfo's class + * list and also files that are annotated with @Entity and @Embeddable in + * the jar files provided in the persistence info. This list of classes will + * used by TopLink to build a deployment project and to decide what classes + * to weave.
+     */
+    public static Collection<Class> buildEntityList(MetadataProcessor processor, ClassLoader loader) {
+        ArrayList<Class> entityList = new ArrayList<Class>();
+        for (String className : processor.getProject().getWeavableClassNames()) {
+            try {
+                Class entityClass = loader.loadClass(className);
+                entityList.add(entityClass);
+            } catch (ClassNotFoundException exc) {
+                AbstractSessionLog.getLog().log(SessionLog.CONFIG, "exception_loading_entity_class", className, exc);
+            }
+        }
+ + return entityList;
+    }

    /**
-     * Return a Set<String> of the classnames represented in the mapping files specified in info.
+ * Return a Set<String> of the classnames represented in the mapping files + * specified in info.
     */
    private static Set<String> buildPersistentClassSetFromXMLDocuments(PersistenceUnitInfo info, ClassLoader loader){
        Set<String> classes = null;
@@ -178,27 +115,48 @@
        // We hand in a null session since none of the functionality required uses a session
        MetadataProcessor processor = new MetadataProcessor(info, null, loader, false);
        processor.readMappingFiles(false);
-        classes = processor.buildEntityClassSetFromXMLDocuments(true, true);
+        classes = processor.buildPersistenceUnitClassSetFromXMLDocuments();
return classes;
    }
- +
+    public static URL computePURootURL(URL pxmlURL) throws IOException {
+        String protocol = pxmlURL.getProtocol();
+        if("file".equals(protocol)) { // NOI18N
+            // e.g. file:/tmp/META-INF/persistence.xml
+            assert(new File(pxmlURL.getFile()).isFile());
+            return new URL(pxmlURL, ".."); // NOI18N
+        } else if("jar".equals(protocol)) { // NOI18N
+            // e.g. jar:file:/tmp/a_ear/b.jar!/META-INF/persistence.xml
+            JarURLConnection conn =
+                    JarURLConnection.class.cast(pxmlURL.openConnection());
+            assert(conn.getJarEntry().getName().equals(
+                    "META-INF/persistence.xml")); // NOI18N
+            return conn.getJarFileURL();
+        } else {
+            // some other protocol,
+            // e.g. bundleresource://21/META-INF/persistence.xml
+            return new URL(pxmlURL, "../"); // NOI18N
+        }
+    }
+
    /**
-     * Search the classpath for persistence archives.  A persistence archive is defined as any
- * part of the class path that contains a META-INF directory with a persistence.xml file in it. - * Return a list of the URLs of those files.
-     * Use the current thread's context classloader to get the classpath.  We assume it is a URL class loader
+ * Search the classpath for persistence archives. A persistence archive is + * defined as any part of the class path that contains a META-INF directory + * with a persistence.xml file in it. Return a list of the URLs of those + * files. Use the current thread's context classloader to get the classpath. + * We assume it is a URL class loader.
     */
    public static Set<Archive> findPersistenceArchives(){
        ClassLoader threadLoader = Thread.currentThread().getContextClassLoader();
        return findPersistenceArchives(threadLoader);
    }

-
    /**
-     * Search the classpath for persistence archives. A persistence archive is defined as any
- * part of the class path that contains a META-INF directory with a persistence.xml file in it.. - * Return a list of {@link Archive} representing the root of those files. + * Search the classpath for persistence archives. A persistence archive is + * defined as any part of the class path that contains a META-INF directory + * with a persistence.xml file in it. Return a list of {@link Archive} + * representing the root of those files.
     * @param loader the class loader to get the class path from
     */
    public static Set<Archive> findPersistenceArchives(ClassLoader loader){
@@ -216,29 +174,10 @@
        } catch (URISyntaxException exc) {
            throw PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(loader, exc);
        }
+ return pars;
    }

-    public static URL computePURootURL(URL pxmlURL) throws IOException {
-        String protocol = pxmlURL.getProtocol();
-        if("file".equals(protocol)) { // NOI18N
-            // e.g. file:/tmp/META-INF/persistence.xml
-            assert(new File(pxmlURL.getFile()).isFile());
-            return new URL(pxmlURL, ".."); // NOI18N
-        } else if("jar".equals(protocol)) { // NOI18N
-            // e.g. jar:file:/tmp/a_ear/b.jar!/META-INF/persistence.xml
-            JarURLConnection conn =
-                    JarURLConnection.class.cast(pxmlURL.openConnection());
-            assert(conn.getJarEntry().getName().equals(
-                    "META-INF/persistence.xml")); // NOI18N
-            return conn.getJarFileURL();
-        } else {
-            // some other protocol,
-            // e.g. bundleresource://21/META-INF/persistence.xml
-            return new URL(pxmlURL, "../"); // NOI18N
-        }
-    }
-
    public static Set<String> getClassNamesFromURL(URL url) {
        Set<String> classNames = new HashSet<String>();
        Archive archive = null;
@@ -249,6 +188,7 @@
        } catch (IOException e) {
            throw new RuntimeException("url = [" + url + "]", e);  // NOI18N
        }
+ for (Iterator<String> entries = archive.getEntries(); entries.hasNext();) {
            String entry = entries.next();
            if (entry.endsWith(".class")){ // NOI18N
@@ -257,96 +197,154 @@
        }
        return classNames;
    }
-
-    public static Set<String> getEntityClassNamesFromURL(URL url, ClassLoader loader, boolean includeEmbedables) {
-        Set<String> entityClassNames = new HashSet<String>();
-        for (String className: getClassNamesFromURL(url)){
-            if (isEntity(className, loader, false, includeEmbedables)){
-                entityClassNames.add(className);
-            }
-        }
-        return entityClassNames;
+ + /** + * Get a list of persitence units from the file or directory at the given + * url. PersistenceUnits are built based on the presence of persistence.xml + * in a META-INF directory at the base of the URL.
+     * @param archive The url of a jar file or directory to check
+     */
+    public static List<SEPersistenceUnitInfo> getPersistenceUnits(Archive archive, ClassLoader loader){
+        return processPersistenceArchive(archive, loader);
    }
-
+ /**
-     * Return whether the class with the given name is annotated with @Entity, @Embedable, or @MappedSuperclass.
+     * Return if a given class is annotated with @Embeddable.
     */
-    public static boolean isEntity(String className, ClassLoader loader, boolean throwExceptionIfNotFound, boolean includeEmbedables){
+    public static boolean isEmbeddable(Class candidateClass){
+        return candidateClass.isAnnotationPresent(javax.persistence.Embeddable.class);
+    }
+ + /**
+     * Return if a given class is annotated with @Entity.
+     */
+    public static boolean isEntity(Class candidateClass){
+        return candidateClass.isAnnotationPresent(javax.persistence.Entity.class);
+    }
+ + /**
+     * Load the given class name with the given class loader.
+     */
+    public static Class loadClass(String className, ClassLoader loader, boolean throwExceptionIfNotFound) {
        Class candidateClass = null;
-        try{
+ + try {
            candidateClass = loader.loadClass(className);
        } catch (ClassNotFoundException exc){
            if (throwExceptionIfNotFound){
                throw PersistenceUnitLoadingException.exceptionLoadingClassWhileLookingForAnnotations(className, exc);
            } else {
                AbstractSessionLog.getLog().log(AbstractSessionLog.WARNING, "persistence_unit_processor_error_loading_class", exc.getClass().getName(), exc.getLocalizedMessage() , className);
- return false; }
        } catch (Exception exception){
            AbstractSessionLog.getLog().log(AbstractSessionLog.WARNING, "persistence_unit_processor_error_loading_class", exception.getClass().getName(), exception.getLocalizedMessage() , className);
-            return false;
        }
-        return isEntity(candidateClass, includeEmbedables);
+ + return candidateClass;
    }
- - /**
-     * Return if a given class is annotated with @Entity, or @Embeddable.
-     * @MappedSuperclass are processed separately.
-     */
-    public static boolean isEntity(Class candidateClass, boolean includeEmbedables){
-        if (candidateClass.isAnnotationPresent(javax.persistence.Entity.class)
-                || (includeEmbedables && candidateClass.isAnnotationPresent(javax.persistence.Embeddable.class))) {
-            return true;
-        }
-        return false;
-    }

    /**
-     * Process the Object/relational metadata from XML and annotations.
+     * Process the Object/relational metadata from XML and annotations
     */
-    public static void processORMetadata(
-            MetadataProcessor processor,
- ClassLoader privateClassLoader, - AbstractSession session,
-            boolean throwExceptionOnFail){
+    public static void processORMetadata(MetadataProcessor processor, ClassLoader privateClassLoader, AbstractSession session, boolean throwExceptionOnFail){
        // DO NOT CHANGE the order of invocation of various methods.

-        // build the list of mapping files and read them. Need to do this before
-        // we start processing entities as the list of entity classes
-        // depend on metadata read from mapping files.
+        // Build the list of mapping files and read them. Need to do this before
+ // we start processing entities as the list of entity classes depend on + // metadata read from mapping files.
        processor.readMappingFiles(throwExceptionOnFail);

-        // process persistence unit metadata/defaults defined in
-        // ORM XML instance documents in the persistence unit
+ // Process persistence unit metadata/defaults defined in ORM XML + // instance documents in the persistence unit
        processor.processPersistenceUnitMetadata();

- //bug:2647 - need to find/process entities after the persistenceUnitMetadata to ensure defaults are overriden. - processor.buildEntityList(); + //bug:2647 - need to find/process entities after the persistenceUnitMetadata to unsure defaults are overriden. + processor.processPersistenceUnitClasses();

+        // Process the actual PU classes metadata from XML.
        processor.processMappingFiles();

-        processor.processAnnotations();
- + // Process the actual PU classes metadata from annotations. + processor.processAnnotations(); } - +
    /**
-     * Create a list of the entities that will be deployed.  This list is build from the information
-     * provided in the PersistenceUnitInfo argument.
-     * The list contains Classes specified in the PersistenceUnitInfo's class list and also
-     * files that are annotated with @Entity and @Embeddable in the jar files provided in the persistence info.
-     * This list of classes will used by TopLink to build a deployment project and to decide what classes to weave.
+ * Go through the jar file for this PeristeneUnitProcessor and process any + * XML provided in it.
     */
-    public static Collection<Class> buildEntityList(MetadataProcessor processor,ClassLoader loader) {
-        ArrayList<Class> entityList = new ArrayList<Class>();
-        for (String className : processor.getProject().getEntityNames()) {
+    public static List<SEPersistenceUnitInfo> processPersistenceArchive(Archive archive, ClassLoader loader){
+        URL puRootURL = archive.getRootURL();
+        try {
+            InputStream pxmlStream = archive.getEntry("META-INF/persistence.xml"); // NOI18N
+            return processPersistenceXML(puRootURL, pxmlStream, loader);
+        } catch (IOException e) {
+            throw PersistenceUnitLoadingException.exceptionLoadingFromUrl(puRootURL.toString(), e);
+        }
+    }
+
+    /**
+     * Build a persistence.xml file into a SEPersistenceUnitInfo object.
+     */
+    private static List<SEPersistenceUnitInfo> processPersistenceXML(URL baseURL, InputStream input, ClassLoader loader){
+        SAXParserFactory spf = SAXParserFactory.newInstance();
+        spf.setNamespaceAware(true);
+        spf.setValidating(true);
+ + XMLReader xmlReader = null;
+        SAXParser sp = null;
+        XMLExceptionHandler xmlErrorHandler = new XMLExceptionHandler();
+
+        // create a SAX parser
+        try {
+            sp = spf.newSAXParser();
+	        sp.setProperty(XMLConstants.SCHEMA_LANGUAGE, XMLConstants.XML_SCHEMA);
+	    } catch (javax.xml.parsers.ParserConfigurationException exc){
+	    	throw XMLParseException.exceptionCreatingSAXParser(baseURL, exc);
+	    } catch (org.xml.sax.SAXException exc){
+	    	throw XMLParseException.exceptionCreatingSAXParser(baseURL, exc);
+	    }
+ + // create an XMLReader
+	    try {
+            xmlReader = sp.getXMLReader();
+	        xmlReader.setErrorHandler(xmlErrorHandler);
+        } catch (org.xml.sax.SAXException exc){
+        	throw XMLParseException.exceptionCreatingXMLReader(baseURL, exc);
+        }
+ + // attempt to load the schema from the classpath
+        URL schemaURL = loader.getResource(XMLConstants.PERSISTENCE_SCHEMA_NAME);
+        if (schemaURL != null) {
            try {
-                Class entityClass = loader.loadClass(className);
-                entityList.add(entityClass);
-            } catch (ClassNotFoundException exc) {
-                AbstractSessionLog.getLog().log(SessionLog.CONFIG,
-                        "exception_loading_entity_class", className, exc);
+            	sp.setProperty(XMLConstants.JAXP_SCHEMA_SOURCE, schemaURL.toString());
+            } catch (org.xml.sax.SAXException exc){
+            	throw XMLParseException.exceptionSettingSchemaSource(baseURL, schemaURL, exc);
            }
        }
-        return entityList;
+
+        PersistenceContentHandler myContentHandler = new PersistenceContentHandler();
+        xmlReader.setContentHandler(myContentHandler);
+
+        InputSource inputSource = new InputSource(input);
+        try{
+            xmlReader.parse(inputSource);
+        } catch (IOException exc){
+            throw PersistenceUnitLoadingException.exceptionProcessingPersistenceXML(baseURL, exc);
+        } catch (org.xml.sax.SAXException exc){
+        	// XMLErrorHandler will handle SAX exceptions
+        }
+ + // handle any parse exceptions
+        XMLException xmlError = xmlErrorHandler.getXMLException();
+        if (xmlError != null) {
+            throw PersistenceUnitLoadingException.exceptionProcessingPersistenceXML(baseURL, xmlError);
+        }
+
+        Iterator<SEPersistenceUnitInfo> persistenceInfos = myContentHandler.getPersistenceUnits().iterator();
+        while (persistenceInfos.hasNext()){
+            SEPersistenceUnitInfo info = persistenceInfos.next();
+ info.setPersistenceUnitRootUrl(baseURL); + }
+        return myContentHandler.getPersistenceUnits();
    }
}
Index: C:/Work/eclipse/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/inheritance/MixedInheritanceJUnitTestCase.java
===================================================================
--- C:/Work/eclipse/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/inheritance/MixedInheritanceJUnitTestCase.java	(revision 3580)
+++ C:/Work/eclipse/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/inheritance/MixedInheritanceJUnitTestCase.java	(working copy)
@@ -15,6 +15,7 @@
import org.eclipse.persistence.testing.models.jpa.inheritance.MudTireInfo;
import org.eclipse.persistence.testing.models.jpa.inheritance.RockTireInfo;
import org.eclipse.persistence.testing.models.jpa.inheritance.TireRating;
+import org.eclipse.persistence.testing.models.jpa.inheritance.TireRatingComment;

import org.eclipse.persistence.testing.models.jpa.inheritance.listeners.TireInfoListener;

@@ -77,7 +78,7 @@
TireRating tireRating = new TireRating();
        tireRating.setRating("Excellent");
-        tireRating.setComments("Tire outperformed all others in adverse conditions");
+        tireRating.setComment(new TireRatingComment("Tire outperformed all others in adverse conditions"));
mudTire.setTireRating(tireRating); Index: C:/Work/eclipse/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inheritance/InheritanceTableCreator.java
===================================================================
--- C:/Work/eclipse/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inheritance/InheritanceTableCreator.java	(revision 3580)
+++ C:/Work/eclipse/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inheritance/InheritanceTableCreator.java	(working copy)
@@ -33,8 +33,8 @@
        addTableDefinition(buildTIREINFOTable());
        addTableDefinition(buildOFFROADTIREINFOTable());
        addTableDefinition(buildMUDTIREINFOTable());
+        addTableDefinition(buildTIRERATINGCOMMENTTable());
        addTableDefinition(buildROCKTIREINFOTable());
-//        addTableDefinition(buildVEH_SEQTable());
        addTableDefinition(buildAAATable());
        addTableDefinition(buildBBBTable());
        addTableDefinition(buildCCCTable());
@@ -332,20 +332,50 @@
        fieldRATING.setShouldAllowNull(true);
        table.addField(fieldRATING);
- FieldDefinition fieldCOMMENTS = new FieldDefinition();
-        fieldCOMMENTS.setName("COMMENTS");
-        fieldCOMMENTS.setTypeName("VARCHAR2");
-        fieldCOMMENTS.setSize(100);
-        fieldCOMMENTS.setSubSize(0);
-        fieldCOMMENTS.setIsPrimaryKey(false);
-        fieldCOMMENTS.setIsIdentity(false);
-        fieldCOMMENTS.setUnique(false);
-        fieldCOMMENTS.setShouldAllowNull(true);
-        table.addField(fieldCOMMENTS);
+        FieldDefinition fieldCOMMENT = new FieldDefinition();
+        fieldCOMMENT.setName("COMMENT_ID");
+        fieldCOMMENT.setTypeName("NUMBER");
+        fieldCOMMENT.setSize(15);
+        fieldCOMMENT.setSubSize(0);
+        fieldCOMMENT.setShouldAllowNull(true);
+        fieldCOMMENT.setIsPrimaryKey(false);
+        fieldCOMMENT.setIsIdentity(false);
+        fieldCOMMENT.setUnique(false);
+        fieldCOMMENT.setForeignKeyFieldName("CMP3_TIRE_RATING_COMMENT.ID");
+        table.addField(fieldCOMMENT);

        return table;
    }
+ public TableDefinition buildTIRERATINGCOMMENTTable() {
+        TableDefinition table = new TableDefinition();
+        table.setName("CMP3_TIRE_RATING_COMMENT");
+
+        FieldDefinition fieldID = new FieldDefinition();
+        fieldID.setName("ID");
+        fieldID.setTypeName("NUMBER");
+        fieldID.setSize(15);
+        fieldID.setSubSize(0);
+        fieldID.setIsPrimaryKey(true);
+        fieldID.setIsIdentity(false);
+        fieldID.setUnique(false);
+        fieldID.setShouldAllowNull(false);
+        table.addField(fieldID);
+ + FieldDefinition fieldDESCRIP = new FieldDefinition();
+        fieldDESCRIP.setName("DESCRIP");
+        fieldDESCRIP.setTypeName("VARCHAR2");
+        fieldDESCRIP.setSize(100);
+        fieldDESCRIP.setSubSize(0);
+        fieldDESCRIP.setIsPrimaryKey(false);
+        fieldDESCRIP.setIsIdentity(false);
+        fieldDESCRIP.setUnique(false);
+        fieldDESCRIP.setShouldAllowNull(true);
+        table.addField(fieldDESCRIP);
+
+        return table;
+    }
+ public TableDefinition buildNONFUEL_VEHTable() {
        TableDefinition table = new TableDefinition();
        table.setName("CMP3_NONFUEL_VEH");
@@ -673,35 +703,6 @@
        return table;
    }

-    public TableDefinition buildVEH_SEQTable() {
-        TableDefinition table = new TableDefinition();
-        table.setName("CMP3_INHERITANCE_SEQ");
-
-        FieldDefinition fieldSEQ_COUNT = new FieldDefinition();
-        fieldSEQ_COUNT.setName("SEQ_COUNT");
-        fieldSEQ_COUNT.setTypeName("NUMBER");
-        fieldSEQ_COUNT.setSize(15);
-        fieldSEQ_COUNT.setSubSize(0);
-        fieldSEQ_COUNT.setIsPrimaryKey(false);
-        fieldSEQ_COUNT.setIsIdentity(false);
-        fieldSEQ_COUNT.setUnique(false);
-        fieldSEQ_COUNT.setShouldAllowNull(false);
-        table.addField(fieldSEQ_COUNT);
-
-        FieldDefinition fieldSEQ_NAME = new FieldDefinition();
-        fieldSEQ_NAME.setName("SEQ_NAME");
-        fieldSEQ_NAME.setTypeName("VARCHAR2");
-        fieldSEQ_NAME.setSize(80);
-        fieldSEQ_NAME.setSubSize(0);
-        fieldSEQ_NAME.setIsPrimaryKey(true);
-        fieldSEQ_NAME.setIsIdentity(false);
-        fieldSEQ_NAME.setUnique(false);
-        fieldSEQ_NAME.setShouldAllowNull(false);
-        table.addField(fieldSEQ_NAME);
-
-        return table;
-    }
-
    public TableDefinition buildAAATable() {
        TableDefinition table = new TableDefinition();
        table.setName("CMP3_AAA");
Index: C:/Work/eclipse/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inheritance/TireRating.java
===================================================================
--- C:/Work/eclipse/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inheritance/TireRating.java	(revision 3580)
+++ C:/Work/eclipse/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inheritance/TireRating.java	(working copy)
@@ -10,16 +10,23 @@
package org.eclipse.persistence.testing.models.jpa.inheritance;

import javax.persistence.Embeddable;
+import javax.persistence.OneToOne;
+import javax.persistence.JoinColumn;

+import static javax.persistence.CascadeType.PERSIST;
+import static javax.persistence.FetchType.LAZY;
+
@Embeddable
public class TireRating {
-    protected String comments;
    protected String rating;
+    protected TireRatingComment comment;
public TireRating() {} - - public String getComments() {
-        return comments;
+
+    @OneToOne(cascade=PERSIST, fetch=LAZY)
+    @JoinColumn(name="COMMENT_ID")
+    public TireRatingComment getComment() {
+        return comment;
    }
public String getRating() {
@@ -30,7 +37,7 @@
        this.rating =rating;
    }
- public void setComments(String comments) {
-        this.comments = comments;
+    public void setComment(TireRatingComment comment) {
+        this.comment = comment;
    }
}
Index: C:/Work/eclipse/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inheritance/TireRatingComment.java
===================================================================
--- C:/Work/eclipse/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inheritance/TireRatingComment.java	(revision 0)
+++ C:/Work/eclipse/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inheritance/TireRatingComment.java	(revision 0)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 1998, 2007 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ *     Oracle - initial API and implementation from Oracle TopLink
+ ******************************************************************************/
+package org.eclipse.persistence.testing.models.jpa.inheritance;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+import static javax.persistence.GenerationType.TABLE;
+
+@Entity
+@Table(name="CMP3_TIRE_RATING_COMMENT")
+public class TireRatingComment  {
+    private Integer id;
+    private String comment;
+ + public TireRatingComment() {} + + public TireRatingComment(String comment) {
+        setComment(comment);
+    }
+ + @Column(name="DESCRIP")
+    public String getComment() {
+        return comment;
+    }
+ + @Id
+    @GeneratedValue(strategy=TABLE, generator="TIRE_RATING_COMMENT_TABLE_GENERATOR")
+	@TableGenerator(
+ name="TIRE_RATING_COMMENT_TABLE_GENERATOR", + table="CMP3_INHERITANCE_SEQ", + pkColumnName="SEQ_NAME", + valueColumnName="SEQ_COUNT",
+        pkColumnValue="TIRE_RATING_COMMENT_SEQ")
+    @Column(name="ID")
+    public Integer getId() {
+        return id;
+    }
+
+    public void setComment(String comment) {
+ this.comment = comment; + } + + public void setId(Integer id) { + this.id = id; + }
+}
\ No newline at end of file

Back to the top