Issue Details (XML | Word | Printable)

Key: NUCCORE-1046
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Trivial Trivial
Assignee: Unassigned
Reporter: Andy Jefferson
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Core

Add check on metadata for abstract class defining a discriminator value (when it won't be used) - log a warning

Created: 28/May/13 07:06 PM   Updated: 09/Dec/13 08:49 PM   Resolved: 28/May/13 07:07 PM
Component/s: MetaData
Affects Version/s: None
Fix Version/s: 3.2.4


Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 28/May/13 07:07 PM
SVN trunk adds this

Chris Colman added a comment - 09/Dec/13 09:42 AM
To avoid the above log message I removed all discriminator value attributes from all abstract classes. What I found was that I now get an error for class hierarchies like this:

AbstractClassA (no discrim value)
    ^
    |
    |
AbstractClassB (no discrim value) <-- Enhancer throws warning for this abstract class
    ^
    |
    |
ConcreteClassC (discrim value)

Wildly speculative theory: It's almost like DN assumes that only the top class in any hierarchy will ever be abstract.

I get the following error:

 [enhancer] Class "com.test.AbstractClassB" has been specified to persist to table of class "com.test.AbstractClassA" using discriminator column classid. No discriminator value has been specified for this class!
 [enhancer] 2013/12/09 19:27:51.317 ERROR - Enhancer - DataNucleus Enhancer completed with an error. Please review the enhancer log (at DEBUG level) for full details. Some classes may have been enhanced but some caused errors
 [enhancer] Class "com.test.AbstractClassB" has been specified to persist to table of class "com.test.AbstractClassA" using discriminator column classid. No discriminator value has been specified for this class!
 [enhancer] org.datanucleus.metadata.InvalidClassMetaDataException: Class "com.test.AbstractClassB" has been specified to persist to table of class "com.test.AbstractClassA" using discriminator column classid. No discriminator value has been specified for this class!
 [enhancer] at org.datanucleus.metadata.AbstractClassMetaData.validateUserInputForInheritanceMetaData(AbstractClassMetaData.java:1001)
 [enhancer] at org.datanucleus.metadata.ClassMetaData.populate(ClassMetaData.java:201)
 [enhancer] at org.datanucleus.metadata.AbstractClassMetaData.validateSuperClass(AbstractClassMetaData.java:786)
 [enhancer] at org.datanucleus.metadata.AbstractClassMetaData.determineSuperClassName(AbstractClassMetaData.java:708)
 [enhancer] at org.datanucleus.metadata.ClassMetaData.populate(ClassMetaData.java:192)
 [enhancer] at org.datanucleus.metadata.AbstractClassMetaData.validateSuperClass(AbstractClassMetaData.java:786)
 [enhancer] at org.datanucleus.metadata.AbstractClassMetaData.determineSuperClassName(AbstractClassMetaData.java:708)
 [enhancer] at org.datanucleus.metadata.ClassMetaData.populate(ClassMetaData.java:192)
 [enhancer] at org.datanucleus.metadata.MetaDataManager$1.run(MetaDataManager.java:2918)
 [enhancer] at java.security.AccessController.doPrivileged(Native Method)
 [enhancer] at org.datanucleus.metadata.MetaDataManager.populateAbstractClassMetaData(MetaDataManager.java:2912)
 [enhancer] at org.datanucleus.metadata.MetaDataManager.populateFileMetaData(MetaDataManager.java:2735)
 [enhancer] at org.datanucleus.metadata.MetaDataManager.initialiseFileMetaDataForUse(MetaDataManager.java:1266)
 [enhancer] at org.datanucleus.metadata.MetaDataManager.loadMetadataFiles(MetaDataManager.java:496)
 [enhancer] at org.datanucleus.enhancer.DataNucleusEnhancer.getFileMetadataForInput(DataNucleusEnhancer.java:752)
 [enhancer] at org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:513)
 [enhancer] at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1281)
 [enhancer] DataNucleus Enhancer completed with an error. Please review the enhancer log (at DEBUG level) for full details. Some classes may have been enhanced but some caused errors
 [enhancer] Java Result: 1

Using DN from Access Platform download 3.3.4
Using table per class hierarchy
Using XML metadata

Will provide a testcase soon if I haven't found a workaround or a fix in the meantime.

Chris Colman added a comment - 09/Dec/13 10:53 AM
I've updated Javelin to generate JDO metadata according to the following rule:
"Leave out discriminator value attribute if class is abstract and it has no superclass"

This avoids the error above but still generates a warning for abstract classes that do have a superclass:
"com.sas.AbstractClassB" is abstract yet has been defined with a discriminator value. The value will never be
used!"

At least a warning is better than an error ;)

Chris Colman added a comment - 09/Dec/13 08:37 PM
Should I raise this error as a separate JIRA issue?

Andy Jefferson added a comment - 09/Dec/13 08:49 PM
Chris, this issue is closed/fixed. You can't reopen something that is closed *and released*.
You can however raise a separate issue that refers to this *with a testcase that demonstrates something*. If there is no testcase then please don't bother, I've really had enough of 'no testcase' issues.