Home » Modeling » EMF » teneo 1.0.1 and DuplicateMappingException
|
Re: teneo 1.0.1 and DuplicateMappingException [message #426059 is a reply to message #426058] |
Mon, 15 December 2008 14:12 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Thomas,
Yes this seems indeed as a strange problem. What you mean is that in the hbm the mapping for each
(e)class occurs twice?
gr. Martin
Thomas wrote:
> Hello,
>
> I try to upgrade from teneo 1.0.0 to teneo 1.0.1 into my project.
> The problem is that on initialization, I have a DuplicateMappingException.
> If I ask the hbm, I see that all my resources are duplicated ...
> With teneo 1.0.0, I don't have this problem. It is quite strange, isn't
> it ?
>
> Thomas
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
| |
Re: teneo 1.0.1 and DuplicateMappingException [message #426062 is a reply to message #426061] |
Mon, 15 December 2008 14:41 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
I am going fine :-).
Can you post the hbm here or email it to me?
gr. Martin
Thomas wrote:
> Hi Martin,
>
> How are you going ?
> I mean when I call dataStore.getMappingXML(), I have twice the <class
> entity-name ... > into the response.
> I was used the lastest release (23 sept 2008)
>
> Martin Taal a écrit :
>> Hi Thomas,
>> Yes this seems indeed as a strange problem. What you mean is that in
>> the hbm the mapping for each (e)class occurs twice?
>>
>> gr. Martin
>>
>> Thomas wrote:
>>> Hello,
>>>
>>> I try to upgrade from teneo 1.0.0 to teneo 1.0.1 into my project.
>>> The problem is that on initialization, I have a
>>> DuplicateMappingException.
>>> If I ask the hbm, I see that all my resources are duplicated ...
>>> With teneo 1.0.0, I don't have this problem. It is quite strange,
>>> isn't it ?
>>>
>>> Thomas
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: teneo 1.0.1 and DuplicateMappingException [message #426064 is a reply to message #426061] |
Mon, 15 December 2008 15:37 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Thomas,
I got your mapping, indeed twice. Can you post how you initialize the datastore? Especially how you
pass the epackages? Do you have subepackages?
gr. Martin
Thomas wrote:
> Hi Martin,
>
> How are you going ?
> I mean when I call dataStore.getMappingXML(), I have twice the <class
> entity-name ... > into the response.
> I was used the lastest release (23 sept 2008)
>
> Martin Taal a écrit :
>> Hi Thomas,
>> Yes this seems indeed as a strange problem. What you mean is that in
>> the hbm the mapping for each (e)class occurs twice?
>>
>> gr. Martin
>>
>> Thomas wrote:
>>> Hello,
>>>
>>> I try to upgrade from teneo 1.0.0 to teneo 1.0.1 into my project.
>>> The problem is that on initialization, I have a
>>> DuplicateMappingException.
>>> If I ask the hbm, I see that all my resources are duplicated ...
>>> With teneo 1.0.0, I don't have this problem. It is quite strange,
>>> isn't it ?
>>>
>>> Thomas
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: teneo 1.0.1 and DuplicateMappingException [message #426065 is a reply to message #426064] |
Mon, 15 December 2008 15:46 |
Thomas Messages: 37 Registered: July 2009 |
Member |
|
|
dataStore = new DreamsHbEntityDataStore();
dataStore.setName(ModelHelper.DREAMS_DATASTORE_NAME);
dataStore = (HbEntityDataStore)
HbHelper.INSTANCE.createRegisterDataStore(ModelHelper.DREAMS _DATASTORE_NAME);
dataStore.setEPackages(new EPackage[] { ModelPackage.eINSTANCE,
EfisPackage.eINSTANCE, MatchingPackage.eINSTANCE,
SchedulingPackage.eINSTANCE, dreamsPackage });
try {
dataStore.initialize();
} finally {
System.out.println(dataStore.getMappingXML());
}
public class DreamsHbEntityDataStore extends HbEntityDataStore {
private static Logger log =
Logger.getLogger(DreamsHbEntityDataStore.class);
@Override
protected Ejb3Configuration createConfiguration() {
// Filter to configure only EMF classes
Ejb3Configuration cfg = new Ejb3Configuration();
Ejb3Configuration configured;
map = new HashMap();
map.put(PersistenceOptions.DISABLE_ECONTAINER_MAPPING, "true");
configured = cfg.configure("Dreams", map);
if (configured == null)
{
log.error("peristence.xml not found.");
throw new RuntimeException("peristence.xml not found.");
}
setProperties(configured.getProperties());
return configured;
}
@Override
protected Iterator<?> getClassMappings() {
Iterator<?> ref = getConfiguration().getClassMappings();
List value = new ArrayList();
while (ref.hasNext()) {
Object object = ref.next();
if (object instanceof PersistentClass) {
PersistentClass PersistentClass = (PersistentClass) object;
if(PersistentClass.getMetaAttribute("eclassName")!=null)
value.add(object);
}
}
return value.iterator();
}
}
Martin Taal a écrit :
> Hi Thomas,
> I got your mapping, indeed twice. Can you post how you initialize the
> datastore? Especially how you pass the epackages? Do you have subepackages?
>
> gr. Martin
>
> Thomas wrote:
>> Hi Martin,
>>
>> How are you going ?
>> I mean when I call dataStore.getMappingXML(), I have twice the <class
>> entity-name ... > into the response.
>> I was used the lastest release (23 sept 2008)
>>
>> Martin Taal a écrit :
>>> Hi Thomas,
>>> Yes this seems indeed as a strange problem. What you mean is that in
>>> the hbm the mapping for each (e)class occurs twice?
>>>
>>> gr. Martin
>>>
>>> Thomas wrote:
>>>> Hello,
>>>>
>>>> I try to upgrade from teneo 1.0.0 to teneo 1.0.1 into my project.
>>>> The problem is that on initialization, I have a
>>>> DuplicateMappingException.
>>>> If I ask the hbm, I see that all my resources are duplicated ...
>>>> With teneo 1.0.0, I don't have this problem. It is quite strange,
>>>> isn't it ?
>>>>
>>>> Thomas
>>>
>>>
>
>
|
|
|
Re: teneo 1.0.1 and DuplicateMappingException [message #426069 is a reply to message #426065] |
Mon, 15 December 2008 16:02 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Thomas,
What is the dreamsPackage? And is one of the packages a subpackage of the other maybe?
gr. Martin
Thomas wrote:
> dataStore = new DreamsHbEntityDataStore();
> dataStore.setName(ModelHelper.DREAMS_DATASTORE_NAME);
> dataStore = (HbEntityDataStore)
> HbHelper.INSTANCE.createRegisterDataStore(ModelHelper.DREAMS _DATASTORE_NAME);
>
> dataStore.setEPackages(new EPackage[] { ModelPackage.eINSTANCE,
> EfisPackage.eINSTANCE, MatchingPackage.eINSTANCE,
> SchedulingPackage.eINSTANCE, dreamsPackage });
>
> try {
> dataStore.initialize();
> } finally {
> System.out.println(dataStore.getMappingXML());
> }
>
> public class DreamsHbEntityDataStore extends HbEntityDataStore {
>
> private static Logger log =
> Logger.getLogger(DreamsHbEntityDataStore.class);
> @Override
> protected Ejb3Configuration createConfiguration() {
> // Filter to configure only EMF classes
> Ejb3Configuration cfg = new Ejb3Configuration();
> Ejb3Configuration configured;
> map = new HashMap();
> map.put(PersistenceOptions.DISABLE_ECONTAINER_MAPPING, "true");
> configured = cfg.configure("Dreams", map);
> if (configured == null)
> {
> log.error("peristence.xml not found.");
> throw new RuntimeException("peristence.xml not found.");
> }
> setProperties(configured.getProperties());
> return configured;
> }
>
> @Override
> protected Iterator<?> getClassMappings() {
> Iterator<?> ref = getConfiguration().getClassMappings();
> List value = new ArrayList();
> while (ref.hasNext()) {
> Object object = ref.next();
> if (object instanceof PersistentClass) {
> PersistentClass PersistentClass = (PersistentClass)
> object;
> if(PersistentClass.getMetaAttribute("eclassName")!=null)
> value.add(object);
> }
> }
> return value.iterator();
> }
> }
>
>
>
> Martin Taal a écrit :
>> Hi Thomas,
>> I got your mapping, indeed twice. Can you post how you initialize the
>> datastore? Especially how you pass the epackages? Do you have
>> subepackages?
>>
>> gr. Martin
>>
>> Thomas wrote:
>>> Hi Martin,
>>>
>>> How are you going ?
>>> I mean when I call dataStore.getMappingXML(), I have twice the <class
>>> entity-name ... > into the response.
>>> I was used the lastest release (23 sept 2008)
>>>
>>> Martin Taal a écrit :
>>>> Hi Thomas,
>>>> Yes this seems indeed as a strange problem. What you mean is that in
>>>> the hbm the mapping for each (e)class occurs twice?
>>>>
>>>> gr. Martin
>>>>
>>>> Thomas wrote:
>>>>> Hello,
>>>>>
>>>>> I try to upgrade from teneo 1.0.0 to teneo 1.0.1 into my project.
>>>>> The problem is that on initialization, I have a
>>>>> DuplicateMappingException.
>>>>> If I ask the hbm, I see that all my resources are duplicated ...
>>>>> With teneo 1.0.0, I don't have this problem. It is quite strange,
>>>>> isn't it ?
>>>>>
>>>>> Thomas
>>>>
>>>>
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: teneo 1.0.1 and DuplicateMappingException [message #426071 is a reply to message #426069] |
Mon, 15 December 2008 16:24 |
Thomas Messages: 37 Registered: July 2009 |
Member |
|
|
org.eclipse.emf.ecore.resource.Resource model = loadModel();
EPackage dreamsPackage = ((EPackage) model.getContents().get(0));
dreamsPackage.setEFactoryInstance(new ModelFactoryImpl());
for (EClassifier eClass : dreamsPackage.getEClassifiers())
{
if (eClass instanceof EClass
&& ((EClass) eClass).getESuperTypes().size() > 0)
{
String superName = ((EClass) eClass).getESuperTypes().get(0).getName();
EClassifier superClass = ModelPackage.eINSTANCE
..getEClassifier(superName);
if (superClass != null && superClass instanceof EClass)
{
((EClass) eClass).getESuperTypes().clear();
((EClass) eClass).getESuperTypes().add((EClass) superClass);
}
for (EStructuralFeature feature : ((EClass) eClass)
.getEAllStructuralFeatures())
{
if (ModelPackage.eINSTANCE.getEClassifier(feature
.getEType().getName()) != null)
{
feature.setEType(ModelPackage.eINSTANCE
.getEClassifier(feature.getEType().getName()));
}
}
}
}
EPackage.Registry.INSTANCE.put(dreamsPackage.getNsURI(), dreamsPackage);
....
public org.eclipse.emf.ecore.resource.Resource loadModel()
{
org.eclipse.emf.ecore.resource.Resource resource = null;
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet
.getResourceFactoryRegistry()
.getExtensionToFactoryMap()
.put(
org.eclipse.emf.ecore.resource.Resource.Factory.Registry.DEF AULT_EXTENSION,
new XMIResourceFactoryImpl());
URL uri = this.getClass().getClassLoader().getResource(
Parameters.getInstance().getEcoreModelFile());
if (uri == null)
{
log.error("Unable to load the model '"
+ Parameters.getInstance().getEcoreModelFile()
+ "' from the classpath.");
// TODO throw an exception
}
resource = resourceSet.getResource(URI.createURI(uri.toString()), true);
log.info("Loaded model at " + uri);
return resource;
}
Martin Taal a écrit :
> Hi Thomas,
> What is the dreamsPackage? And is one of the packages a subpackage of
> the other maybe?
>
> gr. Martin
>
> Thomas wrote:
>> dataStore = new DreamsHbEntityDataStore();
>> dataStore.setName(ModelHelper.DREAMS_DATASTORE_NAME);
>> dataStore = (HbEntityDataStore)
>> HbHelper.INSTANCE.createRegisterDataStore(ModelHelper.DREAMS _DATASTORE_NAME);
>>
>> dataStore.setEPackages(new EPackage[] { ModelPackage.eINSTANCE,
>> EfisPackage.eINSTANCE, MatchingPackage.eINSTANCE,
>> SchedulingPackage.eINSTANCE, dreamsPackage });
>>
>> try {
>> dataStore.initialize();
>> } finally {
>> System.out.println(dataStore.getMappingXML());
>> }
>>
>> public class DreamsHbEntityDataStore extends HbEntityDataStore {
>>
>> private static Logger log =
>> Logger.getLogger(DreamsHbEntityDataStore.class);
>> @Override
>> protected Ejb3Configuration createConfiguration() {
>> // Filter to configure only EMF classes
>> Ejb3Configuration cfg = new Ejb3Configuration();
>> Ejb3Configuration configured;
>> map = new HashMap();
>> map.put(PersistenceOptions.DISABLE_ECONTAINER_MAPPING, "true");
>> configured = cfg.configure("Dreams", map);
>> if (configured == null)
>> {
>> log.error("peristence.xml not found.");
>> throw new RuntimeException("peristence.xml not found.");
>> }
>> setProperties(configured.getProperties());
>> return configured;
>> }
>>
>> @Override
>> protected Iterator<?> getClassMappings() {
>> Iterator<?> ref = getConfiguration().getClassMappings();
>> List value = new ArrayList();
>> while (ref.hasNext()) {
>> Object object = ref.next();
>> if (object instanceof PersistentClass) {
>> PersistentClass PersistentClass = (PersistentClass)
>> object;
>> if(PersistentClass.getMetaAttribute("eclassName")!=null)
>> value.add(object);
>> }
>> }
>> return value.iterator();
>> }
>> }
>>
>>
>>
>> Martin Taal a écrit :
>>> Hi Thomas,
>>> I got your mapping, indeed twice. Can you post how you initialize the
>>> datastore? Especially how you pass the epackages? Do you have
>>> subepackages?
>>>
>>> gr. Martin
>>>
>>> Thomas wrote:
>>>> Hi Martin,
>>>>
>>>> How are you going ?
>>>> I mean when I call dataStore.getMappingXML(), I have twice the
>>>> <class entity-name ... > into the response.
>>>> I was used the lastest release (23 sept 2008)
>>>>
>>>> Martin Taal a écrit :
>>>>> Hi Thomas,
>>>>> Yes this seems indeed as a strange problem. What you mean is that
>>>>> in the hbm the mapping for each (e)class occurs twice?
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Thomas wrote:
>>>>>> Hello,
>>>>>>
>>>>>> I try to upgrade from teneo 1.0.0 to teneo 1.0.1 into my project.
>>>>>> The problem is that on initialization, I have a
>>>>>> DuplicateMappingException.
>>>>>> If I ask the hbm, I see that all my resources are duplicated ...
>>>>>> With teneo 1.0.0, I don't have this problem. It is quite strange,
>>>>>> isn't it ?
>>>>>>
>>>>>> Thomas
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Re: teneo 1.0.1 and DuplicateMappingException [message #426079 is a reply to message #426071] |
Mon, 15 December 2008 19:15 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Thomas,
The only thing I can think of is that the eclasses actually occur twice in the list of eclasses for
which a mapping is generated. Can you set a break point in
HibernateMappingGenerator.processPersistentClasses and then check if you see the same EPackage and
EClasses passing by (same instance and same name/package)?
Then if you see this, backtrack along the stacktrace to see where the duplicates are coming from.
gr. Martin
Thomas wrote:
> org.eclipse.emf.ecore.resource.Resource model = loadModel();
> EPackage dreamsPackage = ((EPackage) model.getContents().get(0));
> dreamsPackage.setEFactoryInstance(new ModelFactoryImpl());
> for (EClassifier eClass : dreamsPackage.getEClassifiers())
> {
> if (eClass instanceof EClass
> && ((EClass) eClass).getESuperTypes().size() > 0)
> {
> String superName = ((EClass)
> eClass).getESuperTypes().get(0).getName();
> EClassifier superClass = ModelPackage.eINSTANCE
> ..getEClassifier(superName);
> if (superClass != null && superClass instanceof EClass)
> {
> ((EClass) eClass).getESuperTypes().clear();
> ((EClass) eClass).getESuperTypes().add((EClass) superClass);
> }
> for (EStructuralFeature feature : ((EClass) eClass)
> .getEAllStructuralFeatures())
> {
> if (ModelPackage.eINSTANCE.getEClassifier(feature
> .getEType().getName()) != null)
> {
> feature.setEType(ModelPackage.eINSTANCE
> .getEClassifier(feature.getEType().getName()));
> }
> }
> }
> }
> EPackage.Registry.INSTANCE.put(dreamsPackage.getNsURI(), dreamsPackage);
>
>
> ....
>
> public org.eclipse.emf.ecore.resource.Resource loadModel()
> {
> org.eclipse.emf.ecore.resource.Resource resource = null;
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet
> .getResourceFactoryRegistry()
> .getExtensionToFactoryMap()
> .put(
>
> org.eclipse.emf.ecore.resource.Resource.Factory.Registry.DEF AULT_EXTENSION,
> new XMIResourceFactoryImpl());
> URL uri = this.getClass().getClassLoader().getResource(
> Parameters.getInstance().getEcoreModelFile());
> if (uri == null)
> {
> log.error("Unable to load the model '"
> + Parameters.getInstance().getEcoreModelFile()
> + "' from the classpath.");
> // TODO throw an exception
> }
> resource =
> resourceSet.getResource(URI.createURI(uri.toString()), true);
> log.info("Loaded model at " + uri);
>
> return resource;
> }
>
> Martin Taal a écrit :
>> Hi Thomas,
>> What is the dreamsPackage? And is one of the packages a subpackage of
>> the other maybe?
>>
>> gr. Martin
>>
>> Thomas wrote:
>>> dataStore = new DreamsHbEntityDataStore();
>>> dataStore.setName(ModelHelper.DREAMS_DATASTORE_NAME);
>>> dataStore = (HbEntityDataStore)
>>> HbHelper.INSTANCE.createRegisterDataStore(ModelHelper.DREAMS _DATASTORE_NAME);
>>>
>>> dataStore.setEPackages(new EPackage[] { ModelPackage.eINSTANCE,
>>> EfisPackage.eINSTANCE, MatchingPackage.eINSTANCE,
>>> SchedulingPackage.eINSTANCE, dreamsPackage });
>>>
>>> try {
>>> dataStore.initialize();
>>> } finally {
>>> System.out.println(dataStore.getMappingXML());
>>> }
>>>
>>> public class DreamsHbEntityDataStore extends HbEntityDataStore {
>>>
>>> private static Logger log =
>>> Logger.getLogger(DreamsHbEntityDataStore.class);
>>> @Override
>>> protected Ejb3Configuration createConfiguration() {
>>> // Filter to configure only EMF classes
>>> Ejb3Configuration cfg = new Ejb3Configuration();
>>> Ejb3Configuration configured;
>>> map = new HashMap();
>>> map.put(PersistenceOptions.DISABLE_ECONTAINER_MAPPING, "true");
>>> configured = cfg.configure("Dreams", map);
>>> if (configured == null)
>>> {
>>> log.error("peristence.xml not found.");
>>> throw new RuntimeException("peristence.xml not found.");
>>> }
>>> setProperties(configured.getProperties());
>>> return configured;
>>> }
>>>
>>> @Override
>>> protected Iterator<?> getClassMappings() {
>>> Iterator<?> ref = getConfiguration().getClassMappings();
>>> List value = new ArrayList();
>>> while (ref.hasNext()) {
>>> Object object = ref.next();
>>> if (object instanceof PersistentClass) {
>>> PersistentClass PersistentClass = (PersistentClass)
>>> object;
>>> if(PersistentClass.getMetaAttribute("eclassName")!=null)
>>> value.add(object);
>>> }
>>> }
>>> return value.iterator();
>>> }
>>> }
>>>
>>>
>>>
>>> Martin Taal a écrit :
>>>> Hi Thomas,
>>>> I got your mapping, indeed twice. Can you post how you initialize
>>>> the datastore? Especially how you pass the epackages? Do you have
>>>> subepackages?
>>>>
>>>> gr. Martin
>>>>
>>>> Thomas wrote:
>>>>> Hi Martin,
>>>>>
>>>>> How are you going ?
>>>>> I mean when I call dataStore.getMappingXML(), I have twice the
>>>>> <class entity-name ... > into the response.
>>>>> I was used the lastest release (23 sept 2008)
>>>>>
>>>>> Martin Taal a écrit :
>>>>>> Hi Thomas,
>>>>>> Yes this seems indeed as a strange problem. What you mean is that
>>>>>> in the hbm the mapping for each (e)class occurs twice?
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Thomas wrote:
>>>>>>> Hello,
>>>>>>>
>>>>>>> I try to upgrade from teneo 1.0.0 to teneo 1.0.1 into my project.
>>>>>>> The problem is that on initialization, I have a
>>>>>>> DuplicateMappingException.
>>>>>>> If I ask the hbm, I see that all my resources are duplicated ...
>>>>>>> With teneo 1.0.0, I don't have this problem. It is quite strange,
>>>>>>> isn't it ?
>>>>>>>
>>>>>>> Thomas
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: teneo 1.0.1 and DuplicateMappingException [message #426163 is a reply to message #426079] |
Wed, 17 December 2008 14:40 |
Thomas Messages: 37 Registered: July 2009 |
Member |
|
|
The problem was in our initialization with the extended model. the
persistence was initialized before the emf was cleaned.
The most strange is in fact how it works with teneo 1.0.0 ???
Martin Taal a écrit :
> Hi Thomas,
> The only thing I can think of is that the eclasses actually occur twice
> in the list of eclasses for which a mapping is generated. Can you set a
> break point in HibernateMappingGenerator.processPersistentClasses and
> then check if you see the same EPackage and EClasses passing by (same
> instance and same name/package)?
> Then if you see this, backtrack along the stacktrace to see where the
> duplicates are coming from.
>
> gr. Martin
>
>
> Thomas wrote:
>> org.eclipse.emf.ecore.resource.Resource model = loadModel();
>> EPackage dreamsPackage = ((EPackage) model.getContents().get(0));
>> dreamsPackage.setEFactoryInstance(new ModelFactoryImpl());
>> for (EClassifier eClass : dreamsPackage.getEClassifiers())
>> {
>> if (eClass instanceof EClass
>> && ((EClass) eClass).getESuperTypes().size() > 0)
>> {
>> String superName = ((EClass)
>> eClass).getESuperTypes().get(0).getName();
>> EClassifier superClass = ModelPackage.eINSTANCE
>> ..getEClassifier(superName);
>> if (superClass != null && superClass instanceof EClass)
>> {
>> ((EClass) eClass).getESuperTypes().clear();
>> ((EClass) eClass).getESuperTypes().add((EClass) superClass);
>> }
>> for (EStructuralFeature feature : ((EClass) eClass)
>> .getEAllStructuralFeatures())
>> {
>> if (ModelPackage.eINSTANCE.getEClassifier(feature
>> .getEType().getName()) != null)
>> {
>> feature.setEType(ModelPackage.eINSTANCE
>> .getEClassifier(feature.getEType().getName()));
>> }
>> }
>> }
>> }
>> EPackage.Registry.INSTANCE.put(dreamsPackage.getNsURI(), dreamsPackage);
>>
>>
>> ....
>>
>> public org.eclipse.emf.ecore.resource.Resource loadModel()
>> {
>> org.eclipse.emf.ecore.resource.Resource resource = null;
>> ResourceSet resourceSet = new ResourceSetImpl();
>> resourceSet
>> .getResourceFactoryRegistry()
>> .getExtensionToFactoryMap()
>> .put(
>>
>> org.eclipse.emf.ecore.resource.Resource.Factory.Registry.DEF AULT_EXTENSION,
>>
>> new XMIResourceFactoryImpl());
>> URL uri = this.getClass().getClassLoader().getResource(
>> Parameters.getInstance().getEcoreModelFile());
>> if (uri == null)
>> {
>> log.error("Unable to load the model '"
>> + Parameters.getInstance().getEcoreModelFile()
>> + "' from the classpath.");
>> // TODO throw an exception
>> }
>> resource =
>> resourceSet.getResource(URI.createURI(uri.toString()), true);
>> log.info("Loaded model at " + uri);
>>
>> return resource;
>> }
>>
>> Martin Taal a écrit :
>>> Hi Thomas,
>>> What is the dreamsPackage? And is one of the packages a subpackage of
>>> the other maybe?
>>>
>>> gr. Martin
>>>
>>> Thomas wrote:
>>>> dataStore = new DreamsHbEntityDataStore();
>>>> dataStore.setName(ModelHelper.DREAMS_DATASTORE_NAME);
>>>> dataStore = (HbEntityDataStore)
>>>> HbHelper.INSTANCE.createRegisterDataStore(ModelHelper.DREAMS _DATASTORE_NAME);
>>>>
>>>> dataStore.setEPackages(new EPackage[] { ModelPackage.eINSTANCE,
>>>> EfisPackage.eINSTANCE, MatchingPackage.eINSTANCE,
>>>> SchedulingPackage.eINSTANCE, dreamsPackage });
>>>>
>>>> try {
>>>> dataStore.initialize();
>>>> } finally {
>>>> System.out.println(dataStore.getMappingXML());
>>>> }
>>>>
>>>> public class DreamsHbEntityDataStore extends HbEntityDataStore {
>>>>
>>>> private static Logger log =
>>>> Logger.getLogger(DreamsHbEntityDataStore.class);
>>>> @Override
>>>> protected Ejb3Configuration createConfiguration() {
>>>> // Filter to configure only EMF classes
>>>> Ejb3Configuration cfg = new Ejb3Configuration();
>>>> Ejb3Configuration configured;
>>>> map = new HashMap();
>>>> map.put(PersistenceOptions.DISABLE_ECONTAINER_MAPPING, "true");
>>>> configured = cfg.configure("Dreams", map);
>>>> if (configured == null)
>>>> {
>>>> log.error("peristence.xml not found.");
>>>> throw new RuntimeException("peristence.xml not found.");
>>>> }
>>>> setProperties(configured.getProperties());
>>>> return configured;
>>>> }
>>>>
>>>> @Override
>>>> protected Iterator<?> getClassMappings() {
>>>> Iterator<?> ref = getConfiguration().getClassMappings();
>>>> List value = new ArrayList();
>>>> while (ref.hasNext()) {
>>>> Object object = ref.next();
>>>> if (object instanceof PersistentClass) {
>>>> PersistentClass PersistentClass = (PersistentClass)
>>>> object;
>>>> if(PersistentClass.getMetaAttribute("eclassName")!=null)
>>>> value.add(object);
>>>> }
>>>> }
>>>> return value.iterator();
>>>> }
>>>> }
>>>>
>>>>
>>>>
>>>> Martin Taal a écrit :
>>>>> Hi Thomas,
>>>>> I got your mapping, indeed twice. Can you post how you initialize
>>>>> the datastore? Especially how you pass the epackages? Do you have
>>>>> subepackages?
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Thomas wrote:
>>>>>> Hi Martin,
>>>>>>
>>>>>> How are you going ?
>>>>>> I mean when I call dataStore.getMappingXML(), I have twice the
>>>>>> <class entity-name ... > into the response.
>>>>>> I was used the lastest release (23 sept 2008)
>>>>>>
>>>>>> Martin Taal a écrit :
>>>>>>> Hi Thomas,
>>>>>>> Yes this seems indeed as a strange problem. What you mean is that
>>>>>>> in the hbm the mapping for each (e)class occurs twice?
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> Thomas wrote:
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> I try to upgrade from teneo 1.0.0 to teneo 1.0.1 into my project.
>>>>>>>> The problem is that on initialization, I have a
>>>>>>>> DuplicateMappingException.
>>>>>>>> If I ask the hbm, I see that all my resources are duplicated ...
>>>>>>>> With teneo 1.0.0, I don't have this problem. It is quite
>>>>>>>> strange, isn't it ?
>>>>>>>>
>>>>>>>> Thomas
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Goto Forum:
Current Time: Fri Sep 20 17:22:11 GMT 2024
Powered by FUDForum. Page generated in 0.04669 seconds
|