Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 313734 - Raw replication does not replicate all types
Summary: Raw replication does not replicate all types
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 3.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Eike Stepper CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-20 10:25 EDT by Erwin Betschart CLA
Modified: 2010-06-29 09:20 EDT (History)
2 users (show)

See Also:


Attachments
Fix for abstract type mappings. (1.05 KB, patch)
2010-06-08 04:47 EDT, Erwin Betschart CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Erwin Betschart CLA 2010-05-20 10:25:18 EDT
Build Identifier: 3.0

The raw replication does not replicate all db tables. Which db tables depends on the already loaded classes.

In AbstractHorizontalMappingStrategy in the method rawExport(IDBStoreAccessor ...) (currently line 108) there is a for loop over all class mappings (line 122). These class mappings are lazily loaded (except during the first start of the repository). Class mappings which are not loaded at the moment of replication will not be transferred to the client.

Btw I worked on a H2 store.

Reproducible: Always
Comment 1 Eike Stepper CLA 2010-06-05 04:06:48 EDT
I added code to create all mappings on demand:

  public final Map<EClass, IClassMapping> getClassMappings(boolean createOnDemand)
  {
    if (createOnDemand)
    {
      synchronized (classMappings)
      {
        if (!allClassMappingsCreated)
        {
          createAllClassMappings();
          allClassMappingsCreated = true;
        }
      }
    }

    return classMappings;
  }

  private void createAllClassMappings()
  {
    InternalRepository repository = (InternalRepository)getStore().getRepository();
    InternalCDOPackageRegistry packageRegistry = repository.getPackageRegistry(false);
    for (InternalCDOPackageInfo packageInfo : packageRegistry.getPackageInfos())
    {
      if (!packageInfo.isSystemPackage())
      {
        for (EClassifier eClassifier : packageInfo.getEPackage().getEClassifiers())
        {
          if (eClassifier instanceof EClass)
          {
            EClass eClass = (EClass)eClassifier;
            getClassMapping(eClass); // Get or create it
          }
        }
      }
    }
  }
Comment 2 Eike Stepper CLA 2010-06-05 04:07:02 EDT
Committed to HEAD
Comment 3 Erwin Betschart CLA 2010-06-08 04:46:43 EDT
Reopening because of raw replication problems. If the emf model contains abstract types the replication fails with a db error message that a certain table does not exists (these are always abstract types).

I'll attach a patch which seems to fix this problem...

1) The number of lines that you added/changed is smaller than 250.
confirmed
2) You are the only author of these changed lines.
confirmed
3) You apply the EPL to these changed lines.
confirmed
Comment 4 Erwin Betschart CLA 2010-06-08 04:47:56 EDT
Created attachment 171375 [details]
Fix for abstract type mappings.

build up class mappings only for non-abstract types.
Comment 5 Eike Stepper CLA 2010-06-08 05:01:15 EDT
Good catch! Thank you ;-)

Committed to HEAD.
Comment 6 Eike Stepper CLA 2010-06-29 04:35:47 EDT
Available in 3.0 GA:
http://download.eclipse.org/modeling/emf/cdo/updates/3.0-releases/