DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCCORE-623
Type: Bug Bug
Status: Closed Closed
Resolution: Cannot Reproduce
Priority: Testcase Required Testcase Required
Assignee: Unassigned
Reporter: Mikhail Moussikhine
Votes: 0
Watchers: 0

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

Extensions are lost during JDO and ORM metadata merge

Created: 07/Jan/11 07:17 AM   Updated: 07/Mar/11 05:34 PM   Resolved: 24/Feb/11 05:29 PM
Component/s: MetaData
Affects Version/s: 2.2.0.release, 2.2.1, 3.0.0.m1
Fix Version/s: None

 Description  « Hide
Class: org.datanucleus.metadata.MetaDataMerger
Function: mergeClassORMData()

During fields merging at:

// C). Add on any fields that weren't defined previously
for (int i=0;i<ormCmd.getNoOfMembers();i++)

Fields extensions in some cases are not copied from ORM metadata to the result metadata. Specifically, at:

// Create a copy of the ORM field MetaData and add to JDO MetaData
if (ormFmd instanceof FieldMetaData)
  fmd = new FieldMetaData(primaryCmd, ormFmd);
  fmd = new PropertyMetaData(primaryCmd, (PropertyMetaData)ormFmd);

Since FieldMetaData (in fact AbstractMemberMetaData) constructor for some reason ignores extensions, resulting field metadata fmd will not have them. This case is triggered if field does not have explicit XML JDO or Annotations metadata, but only ORM one. One line below:

  // Field specified in JDO MetaData so merge in ORM MetaData
  MetaDataMerger.mergeMemberORMData(primaryFmd, ormFmd);

does correctly merge primaryFmd and ormFmd metadata, but this is called only when primaryFmd exists.

The same issue [probably] exists for two other cases in the same repeat block, where identical calls to FieldMetaData and PropertyMetaData constructors are done.

It seems that the code assumes that above mentioned constructors DO copy extensions. Either AbstractMemberMetaData needs to be fixed or if for some reason it is undesirable, then perhaps MetaDataMerger.mergeMemberORMData() must be called unconditionally at the end of each cycle.

Workaround for now is simple: explicitly use @Persistent annotation on every field, but I still think it is major if not critical, since you have to get deep in the code to figure this out.

Andy Jefferson added a comment - 07/Jan/11 08:25 AM
Please provide a testcase that demonstrates some problem, as per all reporting guides

Andy Jefferson made changes - 07/Jan/11 08:25 AM
Field Original Value New Value
Priority Major [ 3 ] Incomplete [ 6 ]
Andy Jefferson made changes - 24/Feb/11 05:29 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Cannot Reproduce [ 5 ]
Andy Jefferson made changes - 07/Mar/11 05:34 PM
Status Resolved [ 5 ] Closed [ 6 ]