Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Duplicate entity name problem in hibernate mapping file.
[Teneo] Duplicate entity name problem in hibernate mapping file. [message #74972] Mon, 12 March 2007 11:10 Go to next message
Duncan Alexander is currently offline Duncan AlexanderFriend
Messages: 90
Registered: July 2009
Member
Hi there,
I am attempting to initialize an HBDataStore with an existing mapping file and am running into
problems with duplicate entity names from different EPackages. I have been through the newsgroups
and found this posting which described the use of QUALIFY_ENTITY_NAME persistence option to work
around the issue.

http://dev.eclipse.org/newslists/news.eclipse.technology.emf t/msg01811.html

I therefore changed my code to the following :

// create the HbDataStore
HbDataStore hbds = HbHelper.INSTANCE.createRegisterDataStore(hbName);
Properties persistenceProperties = new Properties();
persistenceProperties.setProperty(PersistenceOptions.USE_MAP PING_FILE, "true");
persistenceProperties.setProperty(PersistenceOptions.QUALIFY _ENTITY_NAME,
PersistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
hbds.setPersistenceProperties(persistenceProperties);

// sets its epackages stored in this datastore
hbds.setEPackages(new EPackage[]{BasePackage.eINSTANCE,
CategorySchemePackage.eINSTANCE,
KeyFamilyPackage.eINSTANCE,
CodeListPackage.eINSTANCE,
ConceptSchemePackage.eINSTANCE,
ReferencePackage.eINSTANCE,
RegistryPackage.eINSTANCE,
LegacyPackage.eINSTANCE});

// set the relational database to use
hbds.setHibernateProperties(props);

// initialize the Datastore
hbds.initialize();

// Create a session and a transaction
org.hibernate.classic.Session session = hbds.getSessionFactory().openSession();
Transaction tx = session.getTransaction();

// start a transaction
tx.begin();
// Do persistence things etc etc etc.....
tx.commit();
// and close
session.close();
--------------------------------------------------------

However I still get a duplicate entity error as follows:

org.hibernate.DuplicateMappingException: Duplicate class/entity mapping Property
at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
at org.hibernate.cfg.Configuration.add(Configuration.java:669)
at org.hibernate.cfg.Configuration.addInputStream(Configuration .java:504)
at org.eclipse.emf.teneo.hibernate.HbDataStore.mapModel(HbDataS tore.java:363)
at org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
at .....etc etc etc

Is there another persistence option that needs to be set to provide around for duplicate entity names?

Any insights greatly appreciated.

Duncan
Re: [Teneo] Duplicate entity name problem in hibernate mapping file. [message #74979 is a reply to message #74972] Mon, 12 March 2007 11:19 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Duncan,
If you use a mapping file then many options have little/no effect (I should log a warning for this)
as many options (like qualify_entity_names) control how the mapping file is generated.
Mayby you generated the mapping file before setting the Qualify_entity_name option? If so then the
mapping file does not contain qualified entity names.
Note that when you generate the mapping file through the right-click Teneo menu that then no options
are used (so no qualify entity names).

You can generate a mapping file with options using the method: HbHelper.generateMapping.
Or call getMappingXML on the hbdatastore after initializing.

gr. Martin

Duncan ALexander wrote:
> Hi there,
> I am attempting to initialize an HBDataStore with an existing mapping
> file and am running into problems with duplicate entity names from
> different EPackages. I have been through the newsgroups and found this
> posting which described the use of QUALIFY_ENTITY_NAME persistence
> option to work around the issue.
>
> http://dev.eclipse.org/newslists/news.eclipse.technology.emf t/msg01811.html
>
> I therefore changed my code to the following :
>
> // create the HbDataStore
> HbDataStore hbds =
> HbHelper.INSTANCE.createRegisterDataStore(hbName);
> Properties persistenceProperties = new Properties();
>
> persistenceProperties.setProperty(PersistenceOptions.USE_MAP PING_FILE,
> "true");
>
> persistenceProperties.setProperty(PersistenceOptions.QUALIFY _ENTITY_NAME,
>
> PersistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
> hbds.setPersistenceProperties(persistenceProperties);
>
> // sets its epackages stored in this datastore
> hbds.setEPackages(new EPackage[]{BasePackage.eINSTANCE,
> CategorySchemePackage.eINSTANCE,
> KeyFamilyPackage.eINSTANCE,
> CodeListPackage.eINSTANCE,
> ConceptSchemePackage.eINSTANCE,
> ReferencePackage.eINSTANCE,
> RegistryPackage.eINSTANCE,
> LegacyPackage.eINSTANCE});
>
> // set the relational database to use
> hbds.setHibernateProperties(props);
>
> // initialize the Datastore
> hbds.initialize();
>
> // Create a session and a transaction
> org.hibernate.classic.Session session =
> hbds.getSessionFactory().openSession();
> Transaction tx = session.getTransaction();
>
> // start a transaction
> tx.begin();
> // Do persistence things etc etc etc.....
> tx.commit();
> // and close
> session.close();
> --------------------------------------------------------
>
> However I still get a duplicate entity error as follows:
>
> org.hibernate.DuplicateMappingException: Duplicate class/entity mapping
> Property
> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
> at org.hibernate.cfg.Configuration.add(Configuration.java:669)
> at
> org.hibernate.cfg.Configuration.addInputStream(Configuration .java:504)
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.mapModel(HbDataS tore.java:363)
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>
> at .....etc etc etc
>
> Is there another persistence option that needs to be set to provide
> around for duplicate entity names?
>
> Any insights greatly appreciated.
>
> Duncan


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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] Duplicate entity name problem in hibernate mapping file. [message #75063 is a reply to message #74979] Mon, 12 March 2007 12:01 Go to previous messageGo to next message
Duncan Alexander is currently offline Duncan AlexanderFriend
Messages: 90
Registered: July 2009
Member
Hi Martin,
Ok, makes sense. I've now created a method to generate the mapping through the HbHelper. I assume I
will have to move my annotations to a seperate persistence xml file now ? I previously had them
added directly to the ecore files.

Although Ive checked this page http://www.elver.org/hibernate/ejb3_format.html for info on the
annotations file I cant seem to find a complete example anywhere...Im formatting as follows but
Teneo doesnt seem to like it:

<?xml version="1.0" encoding="UTF-8"?>
<persistence-mapping
xmlns="http://www.eclipse.org/emft/teneo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.eclipse.org/emft/teneo persistence-mapping-hibernate.xsd">

<epackage namespace-uri="">
<eclass name="org.sdmx.infomodel.base.Annotable">
<mapped-superclass/>
</eclass>
</epackage>
</persistence-mapping>


What should the namespace-uri of the ePackage be ?

Should I be using the fully qualified Java class as the name ?

Duncan



Martin Taal wrote:
> Hi Duncan,
> If you use a mapping file then many options have little/no effect (I
> should log a warning for this) as many options (like
> qualify_entity_names) control how the mapping file is generated.
> Mayby you generated the mapping file before setting the
> Qualify_entity_name option? If so then the mapping file does not contain
> qualified entity names.
> Note that when you generate the mapping file through the right-click
> Teneo menu that then no options are used (so no qualify entity names).
>
> You can generate a mapping file with options using the method:
> HbHelper.generateMapping.
> Or call getMappingXML on the hbdatastore after initializing.
>
> gr. Martin
>
> Duncan ALexander wrote:
>> Hi there,
>> I am attempting to initialize an HBDataStore with an existing
>> mapping file and am running into problems with duplicate entity names
>> from different EPackages. I have been through the newsgroups and found
>> this posting which described the use of QUALIFY_ENTITY_NAME
>> persistence option to work around the issue.
>>
>> http://dev.eclipse.org/newslists/news.eclipse.technology.emf t/msg01811.html
>>
>>
>> I therefore changed my code to the following :
>>
>> // create the HbDataStore
>> HbDataStore hbds =
>> HbHelper.INSTANCE.createRegisterDataStore(hbName);
>> Properties persistenceProperties = new Properties();
>>
>> persistenceProperties.setProperty(PersistenceOptions.USE_MAP PING_FILE,
>> "true");
>>
>> persistenceProperties.setProperty(PersistenceOptions.QUALIFY _ENTITY_NAME,
>>
>> PersistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
>> hbds.setPersistenceProperties(persistenceProperties);
>>
>> // sets its epackages stored in this datastore
>> hbds.setEPackages(new EPackage[]{BasePackage.eINSTANCE,
>>
>> CategorySchemePackage.eINSTANCE,
>> KeyFamilyPackage.eINSTANCE,
>> CodeListPackage.eINSTANCE,
>>
>> ConceptSchemePackage.eINSTANCE,
>> ReferencePackage.eINSTANCE,
>> RegistryPackage.eINSTANCE,
>> LegacyPackage.eINSTANCE});
>>
>> // set the relational database to use
>> hbds.setHibernateProperties(props);
>>
>> // initialize the Datastore
>> hbds.initialize();
>>
>> // Create a session and a transaction
>> org.hibernate.classic.Session session =
>> hbds.getSessionFactory().openSession();
>> Transaction tx = session.getTransaction();
>>
>> // start a transaction
>> tx.begin();
>> // Do persistence things etc etc etc.....
>> tx.commit();
>> // and close
>> session.close();
>> --------------------------------------------------------
>>
>> However I still get a duplicate entity error as follows:
>>
>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>> mapping Property
>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
>> at org.hibernate.cfg.Configuration.add(Configuration.java:669)
>> at
>> org.hibernate.cfg.Configuration.addInputStream(Configuration .java:504)
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.mapModel(HbDataS tore.java:363)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>
>> at .....etc etc etc
>>
>> Is there another persistence option that needs to be set to provide
>> around for duplicate entity names?
>>
>> Any insights greatly appreciated.
>>
>> Duncan
>
>
Re: [Teneo] Duplicate entity name problem in hibernate mapping file. [message #75075 is a reply to message #75063] Mon, 12 March 2007 12:02 Go to previous messageGo to next message
Duncan Alexander is currently offline Duncan AlexanderFriend
Messages: 90
Registered: July 2009
Member
sorry, ignore the question about the ePackage URI......very obvious to me now !

Duncan

Duncan ALexander wrote:
> Hi Martin,
> Ok, makes sense. I've now created a method to generate the mapping
> through the HbHelper. I assume I will have to move my annotations to a
> seperate persistence xml file now ? I previously had them added directly
> to the ecore files.
>
> Although Ive checked this page
> http://www.elver.org/hibernate/ejb3_format.html for info on the
> annotations file I cant seem to find a complete example anywhere...Im
> formatting as follows but Teneo doesnt seem to like it:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence-mapping
> xmlns="http://www.eclipse.org/emft/teneo"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.eclipse.org/emft/teneo
> persistence-mapping-hibernate.xsd">
>
> <epackage namespace-uri="">
> <eclass name="org.sdmx.infomodel.base.Annotable">
> <mapped-superclass/>
> </eclass>
> </epackage>
> </persistence-mapping>
>
>
> What should the namespace-uri of the ePackage be ?
>
> Should I be using the fully qualified Java class as the name ?
>
> Duncan
>
>
>
> Martin Taal wrote:
>> Hi Duncan,
>> If you use a mapping file then many options have little/no effect (I
>> should log a warning for this) as many options (like
>> qualify_entity_names) control how the mapping file is generated.
>> Mayby you generated the mapping file before setting the
>> Qualify_entity_name option? If so then the mapping file does not
>> contain qualified entity names.
>> Note that when you generate the mapping file through the right-click
>> Teneo menu that then no options are used (so no qualify entity names).
>>
>> You can generate a mapping file with options using the method:
>> HbHelper.generateMapping.
>> Or call getMappingXML on the hbdatastore after initializing.
>>
>> gr. Martin
>>
>> Duncan ALexander wrote:
>>> Hi there,
>>> I am attempting to initialize an HBDataStore with an existing
>>> mapping file and am running into problems with duplicate entity names
>>> from different EPackages. I have been through the newsgroups and
>>> found this posting which described the use of QUALIFY_ENTITY_NAME
>>> persistence option to work around the issue.
>>>
>>> http://dev.eclipse.org/newslists/news.eclipse.technology.emf t/msg01811.html
>>>
>>>
>>> I therefore changed my code to the following :
>>>
>>> // create the HbDataStore
>>> HbDataStore hbds =
>>> HbHelper.INSTANCE.createRegisterDataStore(hbName);
>>> Properties persistenceProperties = new Properties();
>>>
>>> persistenceProperties.setProperty(PersistenceOptions.USE_MAP PING_FILE,
>>> "true");
>>>
>>> persistenceProperties.setProperty(PersistenceOptions.QUALIFY _ENTITY_NAME,
>>>
>>>
>>> PersistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
>>> hbds.setPersistenceProperties(persistenceProperties);
>>>
>>> // sets its epackages stored in this datastore
>>> hbds.setEPackages(new EPackage[]{BasePackage.eINSTANCE,
>>>
>>> CategorySchemePackage.eINSTANCE,
>>> KeyFamilyPackage.eINSTANCE,
>>> CodeListPackage.eINSTANCE,
>>>
>>> ConceptSchemePackage.eINSTANCE,
>>> ReferencePackage.eINSTANCE,
>>> RegistryPackage.eINSTANCE,
>>> LegacyPackage.eINSTANCE});
>>>
>>> // set the relational database to use
>>> hbds.setHibernateProperties(props);
>>>
>>> // initialize the Datastore
>>> hbds.initialize();
>>>
>>> // Create a session and a transaction
>>> org.hibernate.classic.Session session =
>>> hbds.getSessionFactory().openSession();
>>> Transaction tx = session.getTransaction();
>>>
>>> // start a transaction
>>> tx.begin();
>>> // Do persistence things etc etc etc.....
>>> tx.commit();
>>> // and close
>>> session.close();
>>> --------------------------------------------------------
>>>
>>> However I still get a duplicate entity error as follows:
>>>
>>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>>> mapping Property
>>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
>>> at org.hibernate.cfg.Configuration.add(Configuration.java:669)
>>> at
>>> org.hibernate.cfg.Configuration.addInputStream(Configuration .java:504)
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.mapModel(HbDataS tore.java:363)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>
>>> at .....etc etc etc
>>>
>>> Is there another persistence option that needs to be set to provide
>>> around for duplicate entity names?
>>>
>>> Any insights greatly appreciated.
>>>
>>> Duncan
>>
>>
Re: [Teneo] Duplicate entity name problem in hibernate mapping file. [message #75092 is a reply to message #75075] Mon, 12 March 2007 12:19 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
No the annotations need not be in a separate xml file. Only note that when generating the java code
the ecore creation is done programmatically (check out the generated PackageImpl class). So if you
add annotations in ecore then you need to regenerate the java code to get the annotations also
present in the generated PackagImpl.
So overall a separate xml can be easier.

The name attribute of the eclass tag should be set to the eclass name in the ecore (so not the
javaclassname).

gr. Martin

Duncan ALexander wrote:
> sorry, ignore the question about the ePackage URI......very obvious to
> me now !
>
> Duncan
>
> Duncan ALexander wrote:
>> Hi Martin,
>> Ok, makes sense. I've now created a method to generate the mapping
>> through the HbHelper. I assume I will have to move my annotations to a
>> seperate persistence xml file now ? I previously had them added
>> directly to the ecore files.
>>
>> Although Ive checked this page
>> http://www.elver.org/hibernate/ejb3_format.html for info on the
>> annotations file I cant seem to find a complete example anywhere...Im
>> formatting as follows but Teneo doesnt seem to like it:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <persistence-mapping
>> xmlns="http://www.eclipse.org/emft/teneo"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://www.eclipse.org/emft/teneo
>> persistence-mapping-hibernate.xsd">
>>
>> <epackage namespace-uri="">
>> <eclass name="org.sdmx.infomodel.base.Annotable">
>> <mapped-superclass/>
>> </eclass>
>> </epackage>
>> </persistence-mapping>
>>
>>
>> What should the namespace-uri of the ePackage be ?
>>
>> Should I be using the fully qualified Java class as the name ?
>>
>> Duncan
>>
>>
>>
>> Martin Taal wrote:
>>> Hi Duncan,
>>> If you use a mapping file then many options have little/no effect (I
>>> should log a warning for this) as many options (like
>>> qualify_entity_names) control how the mapping file is generated.
>>> Mayby you generated the mapping file before setting the
>>> Qualify_entity_name option? If so then the mapping file does not
>>> contain qualified entity names.
>>> Note that when you generate the mapping file through the right-click
>>> Teneo menu that then no options are used (so no qualify entity names).
>>>
>>> You can generate a mapping file with options using the method:
>>> HbHelper.generateMapping.
>>> Or call getMappingXML on the hbdatastore after initializing.
>>>
>>> gr. Martin
>>>
>>> Duncan ALexander wrote:
>>>> Hi there,
>>>> I am attempting to initialize an HBDataStore with an existing
>>>> mapping file and am running into problems with duplicate entity
>>>> names from different EPackages. I have been through the newsgroups
>>>> and found this posting which described the use of
>>>> QUALIFY_ENTITY_NAME persistence option to work around the issue.
>>>>
>>>> http://dev.eclipse.org/newslists/news.eclipse.technology.emf t/msg01811.html
>>>>
>>>>
>>>> I therefore changed my code to the following :
>>>>
>>>> // create the HbDataStore
>>>> HbDataStore hbds =
>>>> HbHelper.INSTANCE.createRegisterDataStore(hbName);
>>>> Properties persistenceProperties = new Properties();
>>>>
>>>> persistenceProperties.setProperty(PersistenceOptions.USE_MAP PING_FILE,
>>>> "true");
>>>>
>>>> persistenceProperties.setProperty(PersistenceOptions.QUALIFY _ENTITY_NAME,
>>>>
>>>>
>>>> PersistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
>>>> hbds.setPersistenceProperties(persistenceProperties);
>>>>
>>>> // sets its epackages stored in this datastore
>>>> hbds.setEPackages(new EPackage[]{BasePackage.eINSTANCE,
>>>>
>>>> CategorySchemePackage.eINSTANCE,
>>>> KeyFamilyPackage.eINSTANCE,
>>>> CodeListPackage.eINSTANCE,
>>>>
>>>> ConceptSchemePackage.eINSTANCE,
>>>> ReferencePackage.eINSTANCE,
>>>> RegistryPackage.eINSTANCE,
>>>> LegacyPackage.eINSTANCE});
>>>>
>>>> // set the relational database to use
>>>> hbds.setHibernateProperties(props);
>>>>
>>>> // initialize the Datastore
>>>> hbds.initialize();
>>>>
>>>> // Create a session and a transaction
>>>> org.hibernate.classic.Session session =
>>>> hbds.getSessionFactory().openSession();
>>>> Transaction tx = session.getTransaction();
>>>>
>>>> // start a transaction
>>>> tx.begin();
>>>> // Do persistence things etc etc etc.....
>>>> tx.commit();
>>>> // and close
>>>> session.close();
>>>> --------------------------------------------------------
>>>>
>>>> However I still get a duplicate entity error as follows:
>>>>
>>>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>>>> mapping Property
>>>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
>>>> at org.hibernate.cfg.Configuration.add(Configuration.java:669)
>>>> at
>>>> org.hibernate.cfg.Configuration.addInputStream(Configuration .java:504)
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.mapModel(HbDataS tore.java:363)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>>
>>>> at .....etc etc etc
>>>>
>>>> Is there another persistence option that needs to be set to provide
>>>> around for duplicate entity names?
>>>>
>>>> Any insights greatly appreciated.
>>>>
>>>> Duncan
>>>
>>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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] Duplicate entity name problem in hibernate mapping file. [message #75109 is a reply to message #75092] Mon, 12 March 2007 12:36 Go to previous message
Duncan Alexander is currently offline Duncan AlexanderFriend
Messages: 90
Registered: July 2009
Member
Hi Martin,
great, thats it working now. Thanks.

Here is the sample persistence xml for anyone interested...

<?xml version="1.0" encoding="UTF-8"?>
<persistence-mapping
xmlns="http://www.eclipse.org/emft/teneo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.eclipse.org/emft/teneo persistence-mapping-hibernate.xsd">

<epackage namespace-uri="http://www.sdmx.org/resources/infomodel/1.0/base.xmi">
<eclass name="Annotable">
<mapped-superclass/>
</eclass>
</epackage>
</persistence-mapping>

btw...I didnt need to qualify the eclass name with the package ns prefix. I assume that the
namespace uri of the epackage was enough for it to work.

regards

Duncan


Martin Taal wrote:
> No the annotations need not be in a separate xml file. Only note that
> when generating the java code the ecore creation is done
> programmatically (check out the generated PackageImpl class). So if you
> add annotations in ecore then you need to regenerate the java code to
> get the annotations also present in the generated PackagImpl.
> So overall a separate xml can be easier.
>
> The name attribute of the eclass tag should be set to the eclass name in
> the ecore (so not the javaclassname).
>
> gr. Martin
>
> Duncan ALexander wrote:
>> sorry, ignore the question about the ePackage URI......very obvious to
>> me now !
>>
>> Duncan
>>
>> Duncan ALexander wrote:
>>> Hi Martin,
>>> Ok, makes sense. I've now created a method to generate the
>>> mapping through the HbHelper. I assume I will have to move my
>>> annotations to a seperate persistence xml file now ? I previously had
>>> them added directly to the ecore files.
>>>
>>> Although Ive checked this page
>>> http://www.elver.org/hibernate/ejb3_format.html for info on the
>>> annotations file I cant seem to find a complete example anywhere...Im
>>> formatting as follows but Teneo doesnt seem to like it:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <persistence-mapping
>>> xmlns="http://www.eclipse.org/emft/teneo"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xsi:schemaLocation="http://www.eclipse.org/emft/teneo
>>> persistence-mapping-hibernate.xsd">
>>>
>>> <epackage namespace-uri="">
>>> <eclass name="org.sdmx.infomodel.base.Annotable">
>>> <mapped-superclass/>
>>> </eclass>
>>> </epackage>
>>> </persistence-mapping>
>>>
>>>
>>> What should the namespace-uri of the ePackage be ?
>>>
>>> Should I be using the fully qualified Java class as the name ?
>>>
>>> Duncan
>>>
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi Duncan,
>>>> If you use a mapping file then many options have little/no effect (I
>>>> should log a warning for this) as many options (like
>>>> qualify_entity_names) control how the mapping file is generated.
>>>> Mayby you generated the mapping file before setting the
>>>> Qualify_entity_name option? If so then the mapping file does not
>>>> contain qualified entity names.
>>>> Note that when you generate the mapping file through the right-click
>>>> Teneo menu that then no options are used (so no qualify entity names).
>>>>
>>>> You can generate a mapping file with options using the method:
>>>> HbHelper.generateMapping.
>>>> Or call getMappingXML on the hbdatastore after initializing.
>>>>
>>>> gr. Martin
>>>>
>>>> Duncan ALexander wrote:
>>>>> Hi there,
>>>>> I am attempting to initialize an HBDataStore with an existing
>>>>> mapping file and am running into problems with duplicate entity
>>>>> names from different EPackages. I have been through the newsgroups
>>>>> and found this posting which described the use of
>>>>> QUALIFY_ENTITY_NAME persistence option to work around the issue.
>>>>>
>>>>> http://dev.eclipse.org/newslists/news.eclipse.technology.emf t/msg01811.html
>>>>>
>>>>>
>>>>> I therefore changed my code to the following :
>>>>>
>>>>> // create the HbDataStore
>>>>> HbDataStore hbds =
>>>>> HbHelper.INSTANCE.createRegisterDataStore(hbName);
>>>>> Properties persistenceProperties = new Properties();
>>>>>
>>>>> persistenceProperties.setProperty(PersistenceOptions.USE_MAP PING_FILE,
>>>>> "true");
>>>>>
>>>>> persistenceProperties.setProperty(PersistenceOptions.QUALIFY _ENTITY_NAME,
>>>>>
>>>>>
>>>>> PersistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
>>>>> hbds.setPersistenceProperties(persistenceProperties);
>>>>>
>>>>> // sets its epackages stored in this datastore
>>>>> hbds.setEPackages(new EPackage[]{BasePackage.eINSTANCE,
>>>>>
>>>>> CategorySchemePackage.eINSTANCE,
>>>>> KeyFamilyPackage.eINSTANCE,
>>>>> CodeListPackage.eINSTANCE,
>>>>>
>>>>> ConceptSchemePackage.eINSTANCE,
>>>>> ReferencePackage.eINSTANCE,
>>>>> RegistryPackage.eINSTANCE,
>>>>> LegacyPackage.eINSTANCE});
>>>>>
>>>>> // set the relational database to use
>>>>> hbds.setHibernateProperties(props);
>>>>>
>>>>> // initialize the Datastore
>>>>> hbds.initialize();
>>>>>
>>>>> // Create a session and a transaction
>>>>> org.hibernate.classic.Session session =
>>>>> hbds.getSessionFactory().openSession();
>>>>> Transaction tx = session.getTransaction();
>>>>>
>>>>> // start a transaction
>>>>> tx.begin();
>>>>> // Do persistence things etc etc etc.....
>>>>> tx.commit();
>>>>> // and close
>>>>> session.close();
>>>>> --------------------------------------------------------
>>>>>
>>>>> However I still get a duplicate entity error as follows:
>>>>>
>>>>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>>>>> mapping Property
>>>>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>>>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
>>>>> at org.hibernate.cfg.Configuration.add(Configuration.java:669)
>>>>> at
>>>>> org.hibernate.cfg.Configuration.addInputStream(Configuration .java:504)
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.mapModel(HbDataS tore.java:363)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>>>
>>>>> at .....etc etc etc
>>>>>
>>>>> Is there another persistence option that needs to be set to provide
>>>>> around for duplicate entity names?
>>>>>
>>>>> Any insights greatly appreciated.
>>>>>
>>>>> Duncan
>>>>
>>>>
>
>
Re: [Teneo] Duplicate entity name problem in hibernate mapping file. [message #603480 is a reply to message #74972] Mon, 12 March 2007 11:19 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Duncan,
If you use a mapping file then many options have little/no effect (I should log a warning for this)
as many options (like qualify_entity_names) control how the mapping file is generated.
Mayby you generated the mapping file before setting the Qualify_entity_name option? If so then the
mapping file does not contain qualified entity names.
Note that when you generate the mapping file through the right-click Teneo menu that then no options
are used (so no qualify entity names).

You can generate a mapping file with options using the method: HbHelper.generateMapping.
Or call getMappingXML on the hbdatastore after initializing.

gr. Martin

Duncan ALexander wrote:
> Hi there,
> I am attempting to initialize an HBDataStore with an existing mapping
> file and am running into problems with duplicate entity names from
> different EPackages. I have been through the newsgroups and found this
> posting which described the use of QUALIFY_ENTITY_NAME persistence
> option to work around the issue.
>
> http://dev.eclipse.org/newslists/news.eclipse.technology.emf t/msg01811.html
>
> I therefore changed my code to the following :
>
> // create the HbDataStore
> HbDataStore hbds =
> HbHelper.INSTANCE.createRegisterDataStore(hbName);
> Properties persistenceProperties = new Properties();
>
> persistenceProperties.setProperty(PersistenceOptions.USE_MAP PING_FILE,
> "true");
>
> persistenceProperties.setProperty(PersistenceOptions.QUALIFY _ENTITY_NAME,
>
> PersistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
> hbds.setPersistenceProperties(persistenceProperties);
>
> // sets its epackages stored in this datastore
> hbds.setEPackages(new EPackage[]{BasePackage.eINSTANCE,
> CategorySchemePackage.eINSTANCE,
> KeyFamilyPackage.eINSTANCE,
> CodeListPackage.eINSTANCE,
> ConceptSchemePackage.eINSTANCE,
> ReferencePackage.eINSTANCE,
> RegistryPackage.eINSTANCE,
> LegacyPackage.eINSTANCE});
>
> // set the relational database to use
> hbds.setHibernateProperties(props);
>
> // initialize the Datastore
> hbds.initialize();
>
> // Create a session and a transaction
> org.hibernate.classic.Session session =
> hbds.getSessionFactory().openSession();
> Transaction tx = session.getTransaction();
>
> // start a transaction
> tx.begin();
> // Do persistence things etc etc etc.....
> tx.commit();
> // and close
> session.close();
> --------------------------------------------------------
>
> However I still get a duplicate entity error as follows:
>
> org.hibernate.DuplicateMappingException: Duplicate class/entity mapping
> Property
> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
> at org.hibernate.cfg.Configuration.add(Configuration.java:669)
> at
> org.hibernate.cfg.Configuration.addInputStream(Configuration .java:504)
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.mapModel(HbDataS tore.java:363)
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>
> at .....etc etc etc
>
> Is there another persistence option that needs to be set to provide
> around for duplicate entity names?
>
> Any insights greatly appreciated.
>
> Duncan


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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] Duplicate entity name problem in hibernate mapping file. [message #603485 is a reply to message #74979] Mon, 12 March 2007 12:01 Go to previous message
Duncan Alexander is currently offline Duncan AlexanderFriend
Messages: 90
Registered: July 2009
Member
Hi Martin,
Ok, makes sense. I've now created a method to generate the mapping through the HbHelper. I assume I
will have to move my annotations to a seperate persistence xml file now ? I previously had them
added directly to the ecore files.

Although Ive checked this page http://www.elver.org/hibernate/ejb3_format.html for info on the
annotations file I cant seem to find a complete example anywhere...Im formatting as follows but
Teneo doesnt seem to like it:

<?xml version="1.0" encoding="UTF-8"?>
<persistence-mapping
xmlns="http://www.eclipse.org/emft/teneo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.eclipse.org/emft/teneo persistence-mapping-hibernate.xsd">

<epackage namespace-uri="">
<eclass name="org.sdmx.infomodel.base.Annotable">
<mapped-superclass/>
</eclass>
</epackage>
</persistence-mapping>


What should the namespace-uri of the ePackage be ?

Should I be using the fully qualified Java class as the name ?

Duncan



Martin Taal wrote:
> Hi Duncan,
> If you use a mapping file then many options have little/no effect (I
> should log a warning for this) as many options (like
> qualify_entity_names) control how the mapping file is generated.
> Mayby you generated the mapping file before setting the
> Qualify_entity_name option? If so then the mapping file does not contain
> qualified entity names.
> Note that when you generate the mapping file through the right-click
> Teneo menu that then no options are used (so no qualify entity names).
>
> You can generate a mapping file with options using the method:
> HbHelper.generateMapping.
> Or call getMappingXML on the hbdatastore after initializing.
>
> gr. Martin
>
> Duncan ALexander wrote:
>> Hi there,
>> I am attempting to initialize an HBDataStore with an existing
>> mapping file and am running into problems with duplicate entity names
>> from different EPackages. I have been through the newsgroups and found
>> this posting which described the use of QUALIFY_ENTITY_NAME
>> persistence option to work around the issue.
>>
>> http://dev.eclipse.org/newslists/news.eclipse.technology.emf t/msg01811.html
>>
>>
>> I therefore changed my code to the following :
>>
>> // create the HbDataStore
>> HbDataStore hbds =
>> HbHelper.INSTANCE.createRegisterDataStore(hbName);
>> Properties persistenceProperties = new Properties();
>>
>> persistenceProperties.setProperty(PersistenceOptions.USE_MAP PING_FILE,
>> "true");
>>
>> persistenceProperties.setProperty(PersistenceOptions.QUALIFY _ENTITY_NAME,
>>
>> PersistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
>> hbds.setPersistenceProperties(persistenceProperties);
>>
>> // sets its epackages stored in this datastore
>> hbds.setEPackages(new EPackage[]{BasePackage.eINSTANCE,
>>
>> CategorySchemePackage.eINSTANCE,
>> KeyFamilyPackage.eINSTANCE,
>> CodeListPackage.eINSTANCE,
>>
>> ConceptSchemePackage.eINSTANCE,
>> ReferencePackage.eINSTANCE,
>> RegistryPackage.eINSTANCE,
>> LegacyPackage.eINSTANCE});
>>
>> // set the relational database to use
>> hbds.setHibernateProperties(props);
>>
>> // initialize the Datastore
>> hbds.initialize();
>>
>> // Create a session and a transaction
>> org.hibernate.classic.Session session =
>> hbds.getSessionFactory().openSession();
>> Transaction tx = session.getTransaction();
>>
>> // start a transaction
>> tx.begin();
>> // Do persistence things etc etc etc.....
>> tx.commit();
>> // and close
>> session.close();
>> --------------------------------------------------------
>>
>> However I still get a duplicate entity error as follows:
>>
>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>> mapping Property
>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
>> at org.hibernate.cfg.Configuration.add(Configuration.java:669)
>> at
>> org.hibernate.cfg.Configuration.addInputStream(Configuration .java:504)
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.mapModel(HbDataS tore.java:363)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>
>> at .....etc etc etc
>>
>> Is there another persistence option that needs to be set to provide
>> around for duplicate entity names?
>>
>> Any insights greatly appreciated.
>>
>> Duncan
>
>
Re: [Teneo] Duplicate entity name problem in hibernate mapping file. [message #603491 is a reply to message #75063] Mon, 12 March 2007 12:02 Go to previous message
Duncan Alexander is currently offline Duncan AlexanderFriend
Messages: 90
Registered: July 2009
Member
sorry, ignore the question about the ePackage URI......very obvious to me now !

Duncan

Duncan ALexander wrote:
> Hi Martin,
> Ok, makes sense. I've now created a method to generate the mapping
> through the HbHelper. I assume I will have to move my annotations to a
> seperate persistence xml file now ? I previously had them added directly
> to the ecore files.
>
> Although Ive checked this page
> http://www.elver.org/hibernate/ejb3_format.html for info on the
> annotations file I cant seem to find a complete example anywhere...Im
> formatting as follows but Teneo doesnt seem to like it:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence-mapping
> xmlns="http://www.eclipse.org/emft/teneo"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.eclipse.org/emft/teneo
> persistence-mapping-hibernate.xsd">
>
> <epackage namespace-uri="">
> <eclass name="org.sdmx.infomodel.base.Annotable">
> <mapped-superclass/>
> </eclass>
> </epackage>
> </persistence-mapping>
>
>
> What should the namespace-uri of the ePackage be ?
>
> Should I be using the fully qualified Java class as the name ?
>
> Duncan
>
>
>
> Martin Taal wrote:
>> Hi Duncan,
>> If you use a mapping file then many options have little/no effect (I
>> should log a warning for this) as many options (like
>> qualify_entity_names) control how the mapping file is generated.
>> Mayby you generated the mapping file before setting the
>> Qualify_entity_name option? If so then the mapping file does not
>> contain qualified entity names.
>> Note that when you generate the mapping file through the right-click
>> Teneo menu that then no options are used (so no qualify entity names).
>>
>> You can generate a mapping file with options using the method:
>> HbHelper.generateMapping.
>> Or call getMappingXML on the hbdatastore after initializing.
>>
>> gr. Martin
>>
>> Duncan ALexander wrote:
>>> Hi there,
>>> I am attempting to initialize an HBDataStore with an existing
>>> mapping file and am running into problems with duplicate entity names
>>> from different EPackages. I have been through the newsgroups and
>>> found this posting which described the use of QUALIFY_ENTITY_NAME
>>> persistence option to work around the issue.
>>>
>>> http://dev.eclipse.org/newslists/news.eclipse.technology.emf t/msg01811.html
>>>
>>>
>>> I therefore changed my code to the following :
>>>
>>> // create the HbDataStore
>>> HbDataStore hbds =
>>> HbHelper.INSTANCE.createRegisterDataStore(hbName);
>>> Properties persistenceProperties = new Properties();
>>>
>>> persistenceProperties.setProperty(PersistenceOptions.USE_MAP PING_FILE,
>>> "true");
>>>
>>> persistenceProperties.setProperty(PersistenceOptions.QUALIFY _ENTITY_NAME,
>>>
>>>
>>> PersistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
>>> hbds.setPersistenceProperties(persistenceProperties);
>>>
>>> // sets its epackages stored in this datastore
>>> hbds.setEPackages(new EPackage[]{BasePackage.eINSTANCE,
>>>
>>> CategorySchemePackage.eINSTANCE,
>>> KeyFamilyPackage.eINSTANCE,
>>> CodeListPackage.eINSTANCE,
>>>
>>> ConceptSchemePackage.eINSTANCE,
>>> ReferencePackage.eINSTANCE,
>>> RegistryPackage.eINSTANCE,
>>> LegacyPackage.eINSTANCE});
>>>
>>> // set the relational database to use
>>> hbds.setHibernateProperties(props);
>>>
>>> // initialize the Datastore
>>> hbds.initialize();
>>>
>>> // Create a session and a transaction
>>> org.hibernate.classic.Session session =
>>> hbds.getSessionFactory().openSession();
>>> Transaction tx = session.getTransaction();
>>>
>>> // start a transaction
>>> tx.begin();
>>> // Do persistence things etc etc etc.....
>>> tx.commit();
>>> // and close
>>> session.close();
>>> --------------------------------------------------------
>>>
>>> However I still get a duplicate entity error as follows:
>>>
>>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>>> mapping Property
>>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
>>> at org.hibernate.cfg.Configuration.add(Configuration.java:669)
>>> at
>>> org.hibernate.cfg.Configuration.addInputStream(Configuration .java:504)
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.mapModel(HbDataS tore.java:363)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>
>>> at .....etc etc etc
>>>
>>> Is there another persistence option that needs to be set to provide
>>> around for duplicate entity names?
>>>
>>> Any insights greatly appreciated.
>>>
>>> Duncan
>>
>>
Re: [Teneo] Duplicate entity name problem in hibernate mapping file. [message #603495 is a reply to message #75075] Mon, 12 March 2007 12:19 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
No the annotations need not be in a separate xml file. Only note that when generating the java code
the ecore creation is done programmatically (check out the generated PackageImpl class). So if you
add annotations in ecore then you need to regenerate the java code to get the annotations also
present in the generated PackagImpl.
So overall a separate xml can be easier.

The name attribute of the eclass tag should be set to the eclass name in the ecore (so not the
javaclassname).

gr. Martin

Duncan ALexander wrote:
> sorry, ignore the question about the ePackage URI......very obvious to
> me now !
>
> Duncan
>
> Duncan ALexander wrote:
>> Hi Martin,
>> Ok, makes sense. I've now created a method to generate the mapping
>> through the HbHelper. I assume I will have to move my annotations to a
>> seperate persistence xml file now ? I previously had them added
>> directly to the ecore files.
>>
>> Although Ive checked this page
>> http://www.elver.org/hibernate/ejb3_format.html for info on the
>> annotations file I cant seem to find a complete example anywhere...Im
>> formatting as follows but Teneo doesnt seem to like it:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <persistence-mapping
>> xmlns="http://www.eclipse.org/emft/teneo"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://www.eclipse.org/emft/teneo
>> persistence-mapping-hibernate.xsd">
>>
>> <epackage namespace-uri="">
>> <eclass name="org.sdmx.infomodel.base.Annotable">
>> <mapped-superclass/>
>> </eclass>
>> </epackage>
>> </persistence-mapping>
>>
>>
>> What should the namespace-uri of the ePackage be ?
>>
>> Should I be using the fully qualified Java class as the name ?
>>
>> Duncan
>>
>>
>>
>> Martin Taal wrote:
>>> Hi Duncan,
>>> If you use a mapping file then many options have little/no effect (I
>>> should log a warning for this) as many options (like
>>> qualify_entity_names) control how the mapping file is generated.
>>> Mayby you generated the mapping file before setting the
>>> Qualify_entity_name option? If so then the mapping file does not
>>> contain qualified entity names.
>>> Note that when you generate the mapping file through the right-click
>>> Teneo menu that then no options are used (so no qualify entity names).
>>>
>>> You can generate a mapping file with options using the method:
>>> HbHelper.generateMapping.
>>> Or call getMappingXML on the hbdatastore after initializing.
>>>
>>> gr. Martin
>>>
>>> Duncan ALexander wrote:
>>>> Hi there,
>>>> I am attempting to initialize an HBDataStore with an existing
>>>> mapping file and am running into problems with duplicate entity
>>>> names from different EPackages. I have been through the newsgroups
>>>> and found this posting which described the use of
>>>> QUALIFY_ENTITY_NAME persistence option to work around the issue.
>>>>
>>>> http://dev.eclipse.org/newslists/news.eclipse.technology.emf t/msg01811.html
>>>>
>>>>
>>>> I therefore changed my code to the following :
>>>>
>>>> // create the HbDataStore
>>>> HbDataStore hbds =
>>>> HbHelper.INSTANCE.createRegisterDataStore(hbName);
>>>> Properties persistenceProperties = new Properties();
>>>>
>>>> persistenceProperties.setProperty(PersistenceOptions.USE_MAP PING_FILE,
>>>> "true");
>>>>
>>>> persistenceProperties.setProperty(PersistenceOptions.QUALIFY _ENTITY_NAME,
>>>>
>>>>
>>>> PersistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
>>>> hbds.setPersistenceProperties(persistenceProperties);
>>>>
>>>> // sets its epackages stored in this datastore
>>>> hbds.setEPackages(new EPackage[]{BasePackage.eINSTANCE,
>>>>
>>>> CategorySchemePackage.eINSTANCE,
>>>> KeyFamilyPackage.eINSTANCE,
>>>> CodeListPackage.eINSTANCE,
>>>>
>>>> ConceptSchemePackage.eINSTANCE,
>>>> ReferencePackage.eINSTANCE,
>>>> RegistryPackage.eINSTANCE,
>>>> LegacyPackage.eINSTANCE});
>>>>
>>>> // set the relational database to use
>>>> hbds.setHibernateProperties(props);
>>>>
>>>> // initialize the Datastore
>>>> hbds.initialize();
>>>>
>>>> // Create a session and a transaction
>>>> org.hibernate.classic.Session session =
>>>> hbds.getSessionFactory().openSession();
>>>> Transaction tx = session.getTransaction();
>>>>
>>>> // start a transaction
>>>> tx.begin();
>>>> // Do persistence things etc etc etc.....
>>>> tx.commit();
>>>> // and close
>>>> session.close();
>>>> --------------------------------------------------------
>>>>
>>>> However I still get a duplicate entity error as follows:
>>>>
>>>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>>>> mapping Property
>>>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
>>>> at org.hibernate.cfg.Configuration.add(Configuration.java:669)
>>>> at
>>>> org.hibernate.cfg.Configuration.addInputStream(Configuration .java:504)
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.mapModel(HbDataS tore.java:363)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>>
>>>> at .....etc etc etc
>>>>
>>>> Is there another persistence option that needs to be set to provide
>>>> around for duplicate entity names?
>>>>
>>>> Any insights greatly appreciated.
>>>>
>>>> Duncan
>>>
>>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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] Duplicate entity name problem in hibernate mapping file. [message #603502 is a reply to message #75092] Mon, 12 March 2007 12:36 Go to previous message
Duncan Alexander is currently offline Duncan AlexanderFriend
Messages: 90
Registered: July 2009
Member
Hi Martin,
great, thats it working now. Thanks.

Here is the sample persistence xml for anyone interested...

<?xml version="1.0" encoding="UTF-8"?>
<persistence-mapping
xmlns="http://www.eclipse.org/emft/teneo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.eclipse.org/emft/teneo persistence-mapping-hibernate.xsd">

<epackage namespace-uri="http://www.sdmx.org/resources/infomodel/1.0/base.xmi">
<eclass name="Annotable">
<mapped-superclass/>
</eclass>
</epackage>
</persistence-mapping>

btw...I didnt need to qualify the eclass name with the package ns prefix. I assume that the
namespace uri of the epackage was enough for it to work.

regards

Duncan


Martin Taal wrote:
> No the annotations need not be in a separate xml file. Only note that
> when generating the java code the ecore creation is done
> programmatically (check out the generated PackageImpl class). So if you
> add annotations in ecore then you need to regenerate the java code to
> get the annotations also present in the generated PackagImpl.
> So overall a separate xml can be easier.
>
> The name attribute of the eclass tag should be set to the eclass name in
> the ecore (so not the javaclassname).
>
> gr. Martin
>
> Duncan ALexander wrote:
>> sorry, ignore the question about the ePackage URI......very obvious to
>> me now !
>>
>> Duncan
>>
>> Duncan ALexander wrote:
>>> Hi Martin,
>>> Ok, makes sense. I've now created a method to generate the
>>> mapping through the HbHelper. I assume I will have to move my
>>> annotations to a seperate persistence xml file now ? I previously had
>>> them added directly to the ecore files.
>>>
>>> Although Ive checked this page
>>> http://www.elver.org/hibernate/ejb3_format.html for info on the
>>> annotations file I cant seem to find a complete example anywhere...Im
>>> formatting as follows but Teneo doesnt seem to like it:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <persistence-mapping
>>> xmlns="http://www.eclipse.org/emft/teneo"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xsi:schemaLocation="http://www.eclipse.org/emft/teneo
>>> persistence-mapping-hibernate.xsd">
>>>
>>> <epackage namespace-uri="">
>>> <eclass name="org.sdmx.infomodel.base.Annotable">
>>> <mapped-superclass/>
>>> </eclass>
>>> </epackage>
>>> </persistence-mapping>
>>>
>>>
>>> What should the namespace-uri of the ePackage be ?
>>>
>>> Should I be using the fully qualified Java class as the name ?
>>>
>>> Duncan
>>>
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi Duncan,
>>>> If you use a mapping file then many options have little/no effect (I
>>>> should log a warning for this) as many options (like
>>>> qualify_entity_names) control how the mapping file is generated.
>>>> Mayby you generated the mapping file before setting the
>>>> Qualify_entity_name option? If so then the mapping file does not
>>>> contain qualified entity names.
>>>> Note that when you generate the mapping file through the right-click
>>>> Teneo menu that then no options are used (so no qualify entity names).
>>>>
>>>> You can generate a mapping file with options using the method:
>>>> HbHelper.generateMapping.
>>>> Or call getMappingXML on the hbdatastore after initializing.
>>>>
>>>> gr. Martin
>>>>
>>>> Duncan ALexander wrote:
>>>>> Hi there,
>>>>> I am attempting to initialize an HBDataStore with an existing
>>>>> mapping file and am running into problems with duplicate entity
>>>>> names from different EPackages. I have been through the newsgroups
>>>>> and found this posting which described the use of
>>>>> QUALIFY_ENTITY_NAME persistence option to work around the issue.
>>>>>
>>>>> http://dev.eclipse.org/newslists/news.eclipse.technology.emf t/msg01811.html
>>>>>
>>>>>
>>>>> I therefore changed my code to the following :
>>>>>
>>>>> // create the HbDataStore
>>>>> HbDataStore hbds =
>>>>> HbHelper.INSTANCE.createRegisterDataStore(hbName);
>>>>> Properties persistenceProperties = new Properties();
>>>>>
>>>>> persistenceProperties.setProperty(PersistenceOptions.USE_MAP PING_FILE,
>>>>> "true");
>>>>>
>>>>> persistenceProperties.setProperty(PersistenceOptions.QUALIFY _ENTITY_NAME,
>>>>>
>>>>>
>>>>> PersistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
>>>>> hbds.setPersistenceProperties(persistenceProperties);
>>>>>
>>>>> // sets its epackages stored in this datastore
>>>>> hbds.setEPackages(new EPackage[]{BasePackage.eINSTANCE,
>>>>>
>>>>> CategorySchemePackage.eINSTANCE,
>>>>> KeyFamilyPackage.eINSTANCE,
>>>>> CodeListPackage.eINSTANCE,
>>>>>
>>>>> ConceptSchemePackage.eINSTANCE,
>>>>> ReferencePackage.eINSTANCE,
>>>>> RegistryPackage.eINSTANCE,
>>>>> LegacyPackage.eINSTANCE});
>>>>>
>>>>> // set the relational database to use
>>>>> hbds.setHibernateProperties(props);
>>>>>
>>>>> // initialize the Datastore
>>>>> hbds.initialize();
>>>>>
>>>>> // Create a session and a transaction
>>>>> org.hibernate.classic.Session session =
>>>>> hbds.getSessionFactory().openSession();
>>>>> Transaction tx = session.getTransaction();
>>>>>
>>>>> // start a transaction
>>>>> tx.begin();
>>>>> // Do persistence things etc etc etc.....
>>>>> tx.commit();
>>>>> // and close
>>>>> session.close();
>>>>> --------------------------------------------------------
>>>>>
>>>>> However I still get a duplicate entity error as follows:
>>>>>
>>>>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>>>>> mapping Property
>>>>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>>>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
>>>>> at org.hibernate.cfg.Configuration.add(Configuration.java:669)
>>>>> at
>>>>> org.hibernate.cfg.Configuration.addInputStream(Configuration .java:504)
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.mapModel(HbDataS tore.java:363)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>>>
>>>>> at .....etc etc etc
>>>>>
>>>>> Is there another persistence option that needs to be set to provide
>>>>> around for duplicate entity names?
>>>>>
>>>>> Any insights greatly appreciated.
>>>>>
>>>>> Duncan
>>>>
>>>>
>
>
Previous Topic:[Teneo] Duplicate entity name problem in hibernate mapping file.
Next Topic:[Teneo] Null Pointer Exception in HbDataStore ComputeReferers
Goto Forum:
  


Current Time: Sat Oct 31 05:21:53 GMT 2020

Powered by FUDForum. Page generated in 0.03205 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top