Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Teneo: More than one class with same name
Teneo: More than one class with same name [message #69358] Tue, 30 January 2007 11:19 Go to next message
Parvez is currently offline ParvezFriend
Messages: 181
Registered: July 2009
Senior Member
Hi,

As I am having more than one ecore models, it is possible that classes
in different models can have the same name though in different packages.

By default, hibernate file generated by Teneo does not qualify entity
name with package, so that result in duplicate mapping error.

I tried to qualify entities with full package name then hibernate
complains that duplicate import and suggests:

try using auto-import="false"

So just wondering, where & how to specify this?
Though during initialization I specify some hibernate properties using

hbds.setHibernateProperties

and I don’t see this property in Environment class of hibernate.


Another issue is, if in case I don’t want to persist one of the entity
i.e. more than one class with same name in different packages), then I
comment out mapping for that class in hibernate file, but class still
exist in package and Teneo complains that more then one EClass with same
name:

java.lang.IllegalArgumentException: There is more than one EClass with
the same name (. . . . . A different EClassResolver should be used.
at
org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)

Any idea how to solve it?

Thanks.

- Parvez
Re: Teneo: More than one class with same name [message #69379 is a reply to message #69358] Tue, 30 January 2007 11:35 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi,
How did you qualify the entity name (using the QUALIFY_ENTITY_NAME persistenceoption?)? Can you post
the last part of the stacktrace (incl. the exception message)?

With the other issue, are you sure that the mapping xml file is used? You need to tell Teneo
explicitly that a mapping file should be used and where it is used (using the persistenceoption:
PersistenceOptions.USE_MAPPING_FILE).

Can you also post the ecore if the above does not help?

auto-import is set on the hibernate-mapping tag in the mapping xml:
<hibernate-mapping
schema="schemaName" (1)
default-cascade="none|save-update" (2)
auto-import="true|false" (3)
package="package.name" (4)
/>
but I would not try that just now, it should work without setting auto-import explicitly.

gr. Martin

PC wrote:
> Hi,
>
> As I am having more than one ecore models, it is possible that classes
> in different models can have the same name though in different packages.
>
> By default, hibernate file generated by Teneo does not qualify entity
> name with package, so that result in duplicate mapping error.
>
> I tried to qualify entities with full package name then hibernate
> complains that duplicate import and suggests:
>
> try using auto-import="false"
>
> So just wondering, where & how to specify this?
> Though during initialization I specify some hibernate properties using
>
> hbds.setHibernateProperties
>
> and I don’t see this property in Environment class of hibernate.
>
>
> Another issue is, if in case I don’t want to persist one of the entity
> i.e. more than one class with same name in different packages), then I
> comment out mapping for that class in hibernate file, but class still
> exist in package and Teneo complains that more then one EClass with same
> name:
>
> java.lang.IllegalArgumentException: There is more than one EClass with
> the same name (. . . . . A different EClassResolver should be used.
> at
> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>
>
> Any idea how to solve it?
>
> Thanks.
>
> - Parvez


--

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: More than one class with same name [message #69478 is a reply to message #69379] Tue, 30 January 2007 14:50 Go to previous messageGo to next message
Parvez is currently offline ParvezFriend
Messages: 181
Registered: July 2009
Senior Member
Hi Martin,

I am using the option PersistenceOptions.USE_MAPPING_FILE with value "true"
but not the QUALIFY_ENTITY_NAME, I am not sure what should be its value.

In hibernate file, I have added full package name i.e.

<joined-subclass entity-name="com.pilz.pas.network.model.Network" ...
<joined-subclass entity-name="com.pilz.pas.platform.model.Network" ...


Now, I tried changing line to

<hibernate-mapping>
to
<hibernate-mapping auto-import="false">

and I get error::

!MESSAGE There is more than one EClass with the same name (Network in
EPackage model and model. A different EClassResolver should be used.
!STACK 0
java.lang.IllegalArgumentException: There is more than one EClass with
the same name (Network in EPackage model and model. A different
EClassResolver should be used.
at
org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)




If I use:
<hibernate-mapping>

then I get error:

!MESSAGE duplicate import: Network refers to both
com.pilz.pas.network.model.Network and
com.pilz.pas.platform.model.Network (try using auto-import="false")
!STACK 0
org.hibernate.DuplicateMappingException: duplicate import: Network
refers to both com.pilz.pas.network.model.Network and
com.pilz.pas.platform.model.Network (try using auto-import="false")
at org.hibernate.cfg.Mappings.addImport(Mappings.java:141)
at
org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues( HbmBinder.java:614)
at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:527)
at org.hibernate.cfg.HbmBinder.bindJoinedSubclass(HbmBinder.jav a:848)
at org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2202)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
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:360)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)




And if I don’t qualify name i.e. us like

<joined-subclass entity-name="Network" ...

<joined-subclass entity-name="Network" ...

!MESSAGE Duplicate class/entity mapping Network
!STACK 0
org.hibernate.DuplicateMappingException: Duplicate class/entity mapping
Network
at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
at org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2204)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
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:360)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)




If I comment one of the class mapping then I get error:

!MESSAGE There is more than one EClass with the same name (Network in
EPackage model and model. A different EClassResolver should be used.
!STACK 0
java.lang.IllegalArgumentException: There is more than one EClass with
the same name (Network in EPackage model and model. A different
EClassResolver should be used.
at
org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)


- Parvez




Martin Taal wrote:
> Hi,
> How did you qualify the entity name (using the QUALIFY_ENTITY_NAME
> persistenceoption?)? Can you post the last part of the stacktrace (incl.
> the exception message)?
>
> With the other issue, are you sure that the mapping xml file is used?
> You need to tell Teneo explicitly that a mapping file should be used and
> where it is used (using the persistenceoption:
> PersistenceOptions.USE_MAPPING_FILE).
>
> Can you also post the ecore if the above does not help?
>
> auto-import is set on the hibernate-mapping tag in the mapping xml:
> <hibernate-mapping
> schema="schemaName" (1)
> default-cascade="none|save-update" (2)
> auto-import="true|false" (3)
> package="package.name" (4)
> />
> but I would not try that just now, it should work without setting
> auto-import explicitly.
>
> gr. Martin
>
> PC wrote:
>> Hi,
>>
>> As I am having more than one ecore models, it is possible that classes
>> in different models can have the same name though in different packages.
>>
>> By default, hibernate file generated by Teneo does not qualify entity
>> name with package, so that result in duplicate mapping error.
>>
>> I tried to qualify entities with full package name then hibernate
>> complains that duplicate import and suggests:
>>
>> try using auto-import="false"
>>
>> So just wondering, where & how to specify this?
>> Though during initialization I specify some hibernate properties using
>>
>> hbds.setHibernateProperties
>>
>> and I don’t see this property in Environment class of hibernate.
>>
>>
>> Another issue is, if in case I don’t want to persist one of the entity
>> i.e. more than one class with same name in different packages), then I
>> comment out mapping for that class in hibernate file, but class still
>> exist in package and Teneo complains that more then one EClass with
>> same name:
>>
>> java.lang.IllegalArgumentException: There is more than one EClass with
>> the same name (. . . . . A different EClassResolver should be used.
>> at
>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>
>>
>> Any idea how to solve it?
>>
>> Thanks.
>>
>> - Parvez
>
>
Re: Teneo: More than one class with same name [message #69498 is a reply to message #69478] Tue, 30 January 2007 15:38 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Parvez,
It is described here:
http://www.elver.org/hibernate/options.html

see QUALIFY_ENTITY_NAME. If you use that then the naming issue should be solved and you don't need
to edit the xml file.
Btw, the entityname should not be set to the java classname but to the (qualified) eclass name.

See also here:
http://www.elver.org/hibernate/troubleshooting.html#org.hibe rnate.DuplicateMappingException%3A+Duplicate+class%2Fentitym apping

gr. Martin

PC wrote:
> Hi Martin,
>
> I am using the option PersistenceOptions.USE_MAPPING_FILE with value "true"
> but not the QUALIFY_ENTITY_NAME, I am not sure what should be its value.
>
> In hibernate file, I have added full package name i.e.
>
> <joined-subclass entity-name="com.pilz.pas.network.model.Network" ...
> <joined-subclass entity-name="com.pilz.pas.platform.model.Network" ...
>
>
> Now, I tried changing line to
>
> <hibernate-mapping>
> to
> <hibernate-mapping auto-import="false">
>
> and I get error::
>
> !MESSAGE There is more than one EClass with the same name (Network in
> EPackage model and model. A different EClassResolver should be used.
> !STACK 0
> java.lang.IllegalArgumentException: There is more than one EClass with
> the same name (Network in EPackage model and model. A different
> EClassResolver should be used.
> at
> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>
>
>
>
>
> If I use:
> <hibernate-mapping>
>
> then I get error:
>
> !MESSAGE duplicate import: Network refers to both
> com.pilz.pas.network.model.Network and
> com.pilz.pas.platform.model.Network (try using auto-import="false")
> !STACK 0
> org.hibernate.DuplicateMappingException: duplicate import: Network
> refers to both com.pilz.pas.network.model.Network and
> com.pilz.pas.platform.model.Network (try using auto-import="false")
> at org.hibernate.cfg.Mappings.addImport(Mappings.java:141)
> at
> org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues( HbmBinder.java:614)
>
> at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:527)
> at org.hibernate.cfg.HbmBinder.bindJoinedSubclass(HbmBinder.jav a:848)
> at
> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2202)
> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
> 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:360)
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>
>
>
>
>
> And if I don’t qualify name i.e. us like
>
> <joined-subclass entity-name="Network" ...
>
> <joined-subclass entity-name="Network" ...
>
> !MESSAGE Duplicate class/entity mapping Network
> !STACK 0
> org.hibernate.DuplicateMappingException: Duplicate class/entity mapping
> Network
> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
> at
> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2204)
> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
> 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:360)
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>
>
>
>
>
> If I comment one of the class mapping then I get error:
>
> !MESSAGE There is more than one EClass with the same name (Network in
> EPackage model and model. A different EClassResolver should be used.
> !STACK 0
> java.lang.IllegalArgumentException: There is more than one EClass with
> the same name (Network in EPackage model and model. A different
> EClassResolver should be used.
> at
> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>
>
>
> - Parvez
>
>
>
>
> Martin Taal wrote:
>> Hi,
>> How did you qualify the entity name (using the QUALIFY_ENTITY_NAME
>> persistenceoption?)? Can you post the last part of the stacktrace
>> (incl. the exception message)?
>>
>> With the other issue, are you sure that the mapping xml file is used?
>> You need to tell Teneo explicitly that a mapping file should be used
>> and where it is used (using the persistenceoption:
>> PersistenceOptions.USE_MAPPING_FILE).
>>
>> Can you also post the ecore if the above does not help?
>>
>> auto-import is set on the hibernate-mapping tag in the mapping xml:
>> <hibernate-mapping
>> schema="schemaName" (1)
>> default-cascade="none|save-update" (2)
>> auto-import="true|false" (3)
>> package="package.name" (4)
>> />
>> but I would not try that just now, it should work without setting
>> auto-import explicitly.
>>
>> gr. Martin
>>
>> PC wrote:
>>> Hi,
>>>
>>> As I am having more than one ecore models, it is possible that
>>> classes in different models can have the same name though in
>>> different packages.
>>>
>>> By default, hibernate file generated by Teneo does not qualify entity
>>> name with package, so that result in duplicate mapping error.
>>>
>>> I tried to qualify entities with full package name then hibernate
>>> complains that duplicate import and suggests:
>>>
>>> try using auto-import="false"
>>>
>>> So just wondering, where & how to specify this?
>>> Though during initialization I specify some hibernate properties using
>>>
>>> hbds.setHibernateProperties
>>>
>>> and I don’t see this property in Environment class of hibernate.
>>>
>>>
>>> Another issue is, if in case I don’t want to persist one of the
>>> entity i.e. more than one class with same name in different
>>> packages), then I comment out mapping for that class in hibernate
>>> file, but class still exist in package and Teneo complains that more
>>> then one EClass with same name:
>>>
>>> java.lang.IllegalArgumentException: There is more than one EClass
>>> with the same name (. . . . . A different EClassResolver should be used.
>>> at
>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>
>>>
>>> Any idea how to solve it?
>>>
>>> Thanks.
>>>
>>> - Parvez
>>
>>


--

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: More than one class with same name [message #69519 is a reply to message #69498] Tue, 30 January 2007 16:01 Go to previous messageGo to next message
Parvez is currently offline ParvezFriend
Messages: 181
Registered: July 2009
Senior Member
Thanks Martin.

I will try using:

props.setProperty(PersistenceOptions.QUALIFY_ENTITY_NAME,Per sistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);

And I guess, if one hibernate file contains 2 or more classes with same
name then Teneo will use

<meta attribute="epackage">...</meta>

to find package name, is it?

- Parvez

Martin Taal wrote:
> Hi Parvez,
> It is described here:
> http://www.elver.org/hibernate/options.html
>
> see QUALIFY_ENTITY_NAME. If you use that then the naming issue should be
> solved and you don't need to edit the xml file.
> Btw, the entityname should not be set to the java classname but to the
> (qualified) eclass name.
>
> See also here:
> http://www.elver.org/hibernate/troubleshooting.html#org.hibe rnate.DuplicateMappingException%3A+Duplicate+class%2Fentitym apping
>
>
> gr. Martin
>
> PC wrote:
>> Hi Martin,
>>
>> I am using the option PersistenceOptions.USE_MAPPING_FILE with value
>> "true"
>> but not the QUALIFY_ENTITY_NAME, I am not sure what should be its value.
>>
>> In hibernate file, I have added full package name i.e.
>>
>> <joined-subclass entity-name="com.pilz.pas.network.model.Network" ...
>> <joined-subclass entity-name="com.pilz.pas.platform.model.Network" ...
>>
>>
>> Now, I tried changing line to
>>
>> <hibernate-mapping>
>> to
>> <hibernate-mapping auto-import="false">
>>
>> and I get error::
>>
>> !MESSAGE There is more than one EClass with the same name (Network in
>> EPackage model and model. A different EClassResolver should be used.
>> !STACK 0
>> java.lang.IllegalArgumentException: There is more than one EClass with
>> the same name (Network in EPackage model and model. A different
>> EClassResolver should be used.
>> at
>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>
>>
>> If I use:
>> <hibernate-mapping>
>>
>> then I get error:
>>
>> !MESSAGE duplicate import: Network refers to both
>> com.pilz.pas.network.model.Network and
>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>> !STACK 0
>> org.hibernate.DuplicateMappingException: duplicate import: Network
>> refers to both com.pilz.pas.network.model.Network and
>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>> at org.hibernate.cfg.Mappings.addImport(Mappings.java:141)
>> at
>> org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues( HbmBinder.java:614)
>>
>> at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:527)
>> at org.hibernate.cfg.HbmBinder.bindJoinedSubclass(HbmBinder.jav a:848)
>> at
>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2202)
>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>> 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:360)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>
>>
>> And if I don’t qualify name i.e. us like
>>
>> <joined-subclass entity-name="Network" ...
>>
>> <joined-subclass entity-name="Network" ...
>>
>> !MESSAGE Duplicate class/entity mapping Network
>> !STACK 0
>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>> mapping Network
>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>> at
>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2204)
>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>> 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:360)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>
>>
>>
>> If I comment one of the class mapping then I get error:
>>
>> !MESSAGE There is more than one EClass with the same name (Network in
>> EPackage model and model. A different EClassResolver should be used.
>> !STACK 0
>> java.lang.IllegalArgumentException: There is more than one EClass with
>> the same name (Network in EPackage model and model. A different
>> EClassResolver should be used.
>> at
>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>
>> - Parvez
>>
>>
>>
>> Martin Taal wrote:
>>> Hi,
>>> How did you qualify the entity name (using the QUALIFY_ENTITY_NAME
>>> persistenceoption?)? Can you post the last part of the stacktrace
>>> (incl. the exception message)?
>>>
>>> With the other issue, are you sure that the mapping xml file is used?
>>> You need to tell Teneo explicitly that a mapping file should be used
>>> and where it is used (using the persistenceoption:
>>> PersistenceOptions.USE_MAPPING_FILE).
>>>
>>> Can you also post the ecore if the above does not help?
>>>
>>> auto-import is set on the hibernate-mapping tag in the mapping xml:
>>> <hibernate-mapping
>>> schema="schemaName" (1)
>>> default-cascade="none|save-update" (2)
>>> auto-import="true|false" (3)
>>> package="package.name" (4)
>>> />
>>> but I would not try that just now, it should work without setting
>>> auto-import explicitly.
>>>
>>> gr. Martin
>>>
>>> PC wrote:
>>>> Hi,
>>>>
>>>> As I am having more than one ecore models, it is possible that
>>>> classes in different models can have the same name though in
>>>> different packages.
>>>>
>>>> By default, hibernate file generated by Teneo does not qualify
>>>> entity name with package, so that result in duplicate mapping error.
>>>>
>>>> I tried to qualify entities with full package name then hibernate
>>>> complains that duplicate import and suggests:
>>>>
>>>> try using auto-import="false"
>>>>
>>>> So just wondering, where & how to specify this?
>>>> Though during initialization I specify some hibernate properties using
>>>>
>>>> hbds.setHibernateProperties
>>>>
>>>> and I don’t see this property in Environment class of hibernate.
>>>>
>>>>
>>>> Another issue is, if in case I don’t want to persist one of the
>>>> entity i.e. more than one class with same name in different
>>>> packages), then I comment out mapping for that class in hibernate
>>>> file, but class still exist in package and Teneo complains that more
>>>> then one EClass with same name:
>>>>
>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>> with the same name (. . . . . A different EClassResolver should be
>>>> used.
>>>> at
>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>
>>>>
>>>> Any idea how to solve it?
>>>>
>>>> Thanks.
>>>>
>>>> - Parvez
>>>
>>>
>
>
Re: Teneo: More than one class with same name [message #69539 is a reply to message #69519] Tue, 30 January 2007 16:22 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Parvez,
The entity-name in the xml will be qualified. You can set the option and see how the mapping file
looks. Note you need to use the setpersistenceproperties on the hbdatastore for these options (and
setHibernateProperties for the hibernateproperties).

gr. Martin

PC wrote:
> Thanks Martin.
>
> I will try using:
>
> props.setProperty(PersistenceOptions.QUALIFY_ENTITY_NAME,Per sistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
>
>
> And I guess, if one hibernate file contains 2 or more classes with same
> name then Teneo will use
>
> <meta attribute="epackage">...</meta>
>
> to find package name, is it?
>
> - Parvez
>
> Martin Taal wrote:
>> Hi Parvez,
>> It is described here:
>> http://www.elver.org/hibernate/options.html
>>
>> see QUALIFY_ENTITY_NAME. If you use that then the naming issue should
>> be solved and you don't need to edit the xml file.
>> Btw, the entityname should not be set to the java classname but to the
>> (qualified) eclass name.
>>
>> See also here:
>> http://www.elver.org/hibernate/troubleshooting.html#org.hibe rnate.DuplicateMappingException%3A+Duplicate+class%2Fentitym apping
>>
>>
>> gr. Martin
>>
>> PC wrote:
>>> Hi Martin,
>>>
>>> I am using the option PersistenceOptions.USE_MAPPING_FILE with value
>>> "true"
>>> but not the QUALIFY_ENTITY_NAME, I am not sure what should be its value.
>>>
>>> In hibernate file, I have added full package name i.e.
>>>
>>> <joined-subclass entity-name="com.pilz.pas.network.model.Network" ...
>>> <joined-subclass entity-name="com.pilz.pas.platform.model.Network" ...
>>>
>>>
>>> Now, I tried changing line to
>>>
>>> <hibernate-mapping>
>>> to
>>> <hibernate-mapping auto-import="false">
>>>
>>> and I get error::
>>>
>>> !MESSAGE There is more than one EClass with the same name (Network in
>>> EPackage model and model. A different EClassResolver should be used.
>>> !STACK 0
>>> java.lang.IllegalArgumentException: There is more than one EClass
>>> with the same name (Network in EPackage model and model. A different
>>> EClassResolver should be used.
>>> at
>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>
>>> If I use:
>>> <hibernate-mapping>
>>>
>>> then I get error:
>>>
>>> !MESSAGE duplicate import: Network refers to both
>>> com.pilz.pas.network.model.Network and
>>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>>> !STACK 0
>>> org.hibernate.DuplicateMappingException: duplicate import: Network
>>> refers to both com.pilz.pas.network.model.Network and
>>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>>> at org.hibernate.cfg.Mappings.addImport(Mappings.java:141)
>>> at
>>> org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues( HbmBinder.java:614)
>>>
>>> at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:527)
>>> at
>>> org.hibernate.cfg.HbmBinder.bindJoinedSubclass(HbmBinder.jav a:848)
>>> at
>>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2202)
>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>>> 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:360)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>
>>> And if I don’t qualify name i.e. us like
>>>
>>> <joined-subclass entity-name="Network" ...
>>>
>>> <joined-subclass entity-name="Network" ...
>>>
>>> !MESSAGE Duplicate class/entity mapping Network
>>> !STACK 0
>>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>>> mapping Network
>>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>>> at
>>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2204)
>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>>> 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:360)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>
>>>
>>> If I comment one of the class mapping then I get error:
>>>
>>> !MESSAGE There is more than one EClass with the same name (Network in
>>> EPackage model and model. A different EClassResolver should be used.
>>> !STACK 0
>>> java.lang.IllegalArgumentException: There is more than one EClass
>>> with the same name (Network in EPackage model and model. A different
>>> EClassResolver should be used.
>>> at
>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>
>>> - Parvez
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi,
>>>> How did you qualify the entity name (using the QUALIFY_ENTITY_NAME
>>>> persistenceoption?)? Can you post the last part of the stacktrace
>>>> (incl. the exception message)?
>>>>
>>>> With the other issue, are you sure that the mapping xml file is
>>>> used? You need to tell Teneo explicitly that a mapping file should
>>>> be used and where it is used (using the persistenceoption:
>>>> PersistenceOptions.USE_MAPPING_FILE).
>>>>
>>>> Can you also post the ecore if the above does not help?
>>>>
>>>> auto-import is set on the hibernate-mapping tag in the mapping xml:
>>>> <hibernate-mapping
>>>> schema="schemaName" (1)
>>>> default-cascade="none|save-update" (2)
>>>> auto-import="true|false" (3)
>>>> package="package.name" (4)
>>>> />
>>>> but I would not try that just now, it should work without setting
>>>> auto-import explicitly.
>>>>
>>>> gr. Martin
>>>>
>>>> PC wrote:
>>>>> Hi,
>>>>>
>>>>> As I am having more than one ecore models, it is possible that
>>>>> classes in different models can have the same name though in
>>>>> different packages.
>>>>>
>>>>> By default, hibernate file generated by Teneo does not qualify
>>>>> entity name with package, so that result in duplicate mapping error.
>>>>>
>>>>> I tried to qualify entities with full package name then hibernate
>>>>> complains that duplicate import and suggests:
>>>>>
>>>>> try using auto-import="false"
>>>>>
>>>>> So just wondering, where & how to specify this?
>>>>> Though during initialization I specify some hibernate properties using
>>>>>
>>>>> hbds.setHibernateProperties
>>>>>
>>>>> and I don’t see this property in Environment class of hibernate.
>>>>>
>>>>>
>>>>> Another issue is, if in case I don’t want to persist one of the
>>>>> entity i.e. more than one class with same name in different
>>>>> packages), then I comment out mapping for that class in hibernate
>>>>> file, but class still exist in package and Teneo complains that
>>>>> more then one EClass with same name:
>>>>>
>>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>>> with the same name (. . . . . A different EClassResolver should be
>>>>> used.
>>>>> at
>>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>>
>>>>>
>>>>> Any idea how to solve it?
>>>>>
>>>>> Thanks.
>>>>>
>>>>> - Parvez
>>>>
>>>>
>>
>>


--

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: More than one class with same name [message #69559 is a reply to message #69539] Tue, 30 January 2007 17:17 Go to previous messageGo to next message
Parvez is currently offline ParvezFriend
Messages: 181
Registered: July 2009
Senior Member
Sorry Martin, I "think" may be I got confused now about how
QUALIFY_ENTITY_NAME is going to work.

It looks to me that this option may not work for me, because I generate
hibernate file before running the application i.e. by right clicking on
ecore file and I use PersistenceOptions.USE_MAPPING_FILE, "true".
So I guess that won’t change hibernate file, but may be it can update
the loaded xml data. I will try it and will update accordingly.

- Parvez

Martin Taal wrote:
> Hi Parvez,
> The entity-name in the xml will be qualified. You can set the option and
> see how the mapping file looks. Note you need to use the
> setpersistenceproperties on the hbdatastore for these options (and
> setHibernateProperties for the hibernateproperties).
>
> gr. Martin
>
> PC wrote:
>> Thanks Martin.
>>
>> I will try using:
>>
>> props.setProperty(PersistenceOptions.QUALIFY_ENTITY_NAME,Per sistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
>>
>>
>> And I guess, if one hibernate file contains 2 or more classes with
>> same name then Teneo will use
>>
>> <meta attribute="epackage">...</meta>
>>
>> to find package name, is it?
>>
>> - Parvez
>>
>> Martin Taal wrote:
>>> Hi Parvez,
>>> It is described here:
>>> http://www.elver.org/hibernate/options.html
>>>
>>> see QUALIFY_ENTITY_NAME. If you use that then the naming issue should
>>> be solved and you don't need to edit the xml file.
>>> Btw, the entityname should not be set to the java classname but to
>>> the (qualified) eclass name.
>>>
>>> See also here:
>>> http://www.elver.org/hibernate/troubleshooting.html#org.hibe rnate.DuplicateMappingException%3A+Duplicate+class%2Fentitym apping
>>>
>>>
>>> gr. Martin
>>>
>>> PC wrote:
>>>> Hi Martin,
>>>>
>>>> I am using the option PersistenceOptions.USE_MAPPING_FILE with value
>>>> "true"
>>>> but not the QUALIFY_ENTITY_NAME, I am not sure what should be its
>>>> value.
>>>>
>>>> In hibernate file, I have added full package name i.e.
>>>>
>>>> <joined-subclass entity-name="com.pilz.pas.network.model.Network" ...
>>>> <joined-subclass entity-name="com.pilz.pas.platform.model.Network" ...
>>>>
>>>>
>>>> Now, I tried changing line to
>>>>
>>>> <hibernate-mapping>
>>>> to
>>>> <hibernate-mapping auto-import="false">
>>>>
>>>> and I get error::
>>>>
>>>> !MESSAGE There is more than one EClass with the same name (Network
>>>> in EPackage model and model. A different EClassResolver should be used.
>>>> !STACK 0
>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>> with the same name (Network in EPackage model and model. A different
>>>> EClassResolver should be used.
>>>> at
>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>
>>>> If I use:
>>>> <hibernate-mapping>
>>>>
>>>> then I get error:
>>>>
>>>> !MESSAGE duplicate import: Network refers to both
>>>> com.pilz.pas.network.model.Network and
>>>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>>>> !STACK 0
>>>> org.hibernate.DuplicateMappingException: duplicate import: Network
>>>> refers to both com.pilz.pas.network.model.Network and
>>>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>>>> at org.hibernate.cfg.Mappings.addImport(Mappings.java:141)
>>>> at
>>>> org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues( HbmBinder.java:614)
>>>>
>>>> at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:527)
>>>> at
>>>> org.hibernate.cfg.HbmBinder.bindJoinedSubclass(HbmBinder.jav a:848)
>>>> at
>>>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2202)
>>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>>>> 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:360)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>>
>>>> And if I don’t qualify name i.e. us like
>>>>
>>>> <joined-subclass entity-name="Network" ...
>>>>
>>>> <joined-subclass entity-name="Network" ...
>>>>
>>>> !MESSAGE Duplicate class/entity mapping Network
>>>> !STACK 0
>>>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>>>> mapping Network
>>>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>>>> at
>>>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2204)
>>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>>>> 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:360)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>>
>>>> If I comment one of the class mapping then I get error:
>>>>
>>>> !MESSAGE There is more than one EClass with the same name (Network
>>>> in EPackage model and model. A different EClassResolver should be used.
>>>> !STACK 0
>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>> with the same name (Network in EPackage model and model. A different
>>>> EClassResolver should be used.
>>>> at
>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>
>>>> - Parvez
>>>>
>>>> Martin Taal wrote:
>>>>> Hi,
>>>>> How did you qualify the entity name (using the QUALIFY_ENTITY_NAME
>>>>> persistenceoption?)? Can you post the last part of the stacktrace
>>>>> (incl. the exception message)?
>>>>>
>>>>> With the other issue, are you sure that the mapping xml file is
>>>>> used? You need to tell Teneo explicitly that a mapping file should
>>>>> be used and where it is used (using the persistenceoption:
>>>>> PersistenceOptions.USE_MAPPING_FILE).
>>>>>
>>>>> Can you also post the ecore if the above does not help?
>>>>>
>>>>> auto-import is set on the hibernate-mapping tag in the mapping xml:
>>>>> <hibernate-mapping
>>>>> schema="schemaName" (1)
>>>>> default-cascade="none|save-update" (2)
>>>>> auto-import="true|false" (3)
>>>>> package="package.name" (4)
>>>>> />
>>>>> but I would not try that just now, it should work without setting
>>>>> auto-import explicitly.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> PC wrote:
>>>>>> Hi,
>>>>>>
>>>>>> As I am having more than one ecore models, it is possible that
>>>>>> classes in different models can have the same name though in
>>>>>> different packages.
>>>>>>
>>>>>> By default, hibernate file generated by Teneo does not qualify
>>>>>> entity name with package, so that result in duplicate mapping error.
>>>>>>
>>>>>> I tried to qualify entities with full package name then hibernate
>>>>>> complains that duplicate import and suggests:
>>>>>>
>>>>>> try using auto-import="false"
>>>>>>
>>>>>> So just wondering, where & how to specify this?
>>>>>> Though during initialization I specify some hibernate properties
>>>>>> using
>>>>>>
>>>>>> hbds.setHibernateProperties
>>>>>>
>>>>>> and I don’t see this property in Environment class of hibernate.
>>>>>>
>>>>>>
>>>>>> Another issue is, if in case I don’t want to persist one of the
>>>>>> entity i.e. more than one class with same name in different
>>>>>> packages), then I comment out mapping for that class in hibernate
>>>>>> file, but class still exist in package and Teneo complains that
>>>>>> more then one EClass with same name:
>>>>>>
>>>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>>>> with the same name (. . . . . A different EClassResolver should be
>>>>>> used.
>>>>>> at
>>>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>>>
>>>>>>
>>>>>> Any idea how to solve it?
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> - Parvez
>>>>>
>>>>>
>>>
>>>
>
>
Re: Teneo: More than one class with same name [message #69579 is a reply to message #69559] Tue, 30 January 2007 17:24 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Updating the loaded xml will not work I think (afaik).

You can also write a small java app (with just a static main method) which calls
HbHelper.INSTANCE.generateMapping to generate a mapping file. This method allows you to pass the
persistenceproperties.

gr. Martin

PC wrote:
> Sorry Martin, I "think" may be I got confused now about how
> QUALIFY_ENTITY_NAME is going to work.
>
> It looks to me that this option may not work for me, because I generate
> hibernate file before running the application i.e. by right clicking on
> ecore file and I use PersistenceOptions.USE_MAPPING_FILE, "true".
> So I guess that won’t change hibernate file, but may be it can update
> the loaded xml data. I will try it and will update accordingly.
>
> - Parvez
>
> Martin Taal wrote:
>> Hi Parvez,
>> The entity-name in the xml will be qualified. You can set the option
>> and see how the mapping file looks. Note you need to use the
>> setpersistenceproperties on the hbdatastore for these options (and
>> setHibernateProperties for the hibernateproperties).
>>
>> gr. Martin
>>
>> PC wrote:
>>> Thanks Martin.
>>>
>>> I will try using:
>>>
>>> props.setProperty(PersistenceOptions.QUALIFY_ENTITY_NAME,Per sistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
>>>
>>>
>>> And I guess, if one hibernate file contains 2 or more classes with
>>> same name then Teneo will use
>>>
>>> <meta attribute="epackage">...</meta>
>>>
>>> to find package name, is it?
>>>
>>> - Parvez
>>>
>>> Martin Taal wrote:
>>>> Hi Parvez,
>>>> It is described here:
>>>> http://www.elver.org/hibernate/options.html
>>>>
>>>> see QUALIFY_ENTITY_NAME. If you use that then the naming issue
>>>> should be solved and you don't need to edit the xml file.
>>>> Btw, the entityname should not be set to the java classname but to
>>>> the (qualified) eclass name.
>>>>
>>>> See also here:
>>>> http://www.elver.org/hibernate/troubleshooting.html#org.hibe rnate.DuplicateMappingException%3A+Duplicate+class%2Fentitym apping
>>>>
>>>>
>>>> gr. Martin
>>>>
>>>> PC wrote:
>>>>> Hi Martin,
>>>>>
>>>>> I am using the option PersistenceOptions.USE_MAPPING_FILE with
>>>>> value "true"
>>>>> but not the QUALIFY_ENTITY_NAME, I am not sure what should be its
>>>>> value.
>>>>>
>>>>> In hibernate file, I have added full package name i.e.
>>>>>
>>>>> <joined-subclass entity-name="com.pilz.pas.network.model.Network" ...
>>>>> <joined-subclass entity-name="com.pilz.pas.platform.model.Network" ...
>>>>>
>>>>>
>>>>> Now, I tried changing line to
>>>>>
>>>>> <hibernate-mapping>
>>>>> to
>>>>> <hibernate-mapping auto-import="false">
>>>>>
>>>>> and I get error::
>>>>>
>>>>> !MESSAGE There is more than one EClass with the same name (Network
>>>>> in EPackage model and model. A different EClassResolver should be
>>>>> used.
>>>>> !STACK 0
>>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>>> with the same name (Network in EPackage model and model. A
>>>>> different EClassResolver should be used.
>>>>> at
>>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>>
>>>>> If I use:
>>>>> <hibernate-mapping>
>>>>>
>>>>> then I get error:
>>>>>
>>>>> !MESSAGE duplicate import: Network refers to both
>>>>> com.pilz.pas.network.model.Network and
>>>>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>>>>> !STACK 0
>>>>> org.hibernate.DuplicateMappingException: duplicate import: Network
>>>>> refers to both com.pilz.pas.network.model.Network and
>>>>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>>>>> at org.hibernate.cfg.Mappings.addImport(Mappings.java:141)
>>>>> at
>>>>> org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues( HbmBinder.java:614)
>>>>>
>>>>> at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:527)
>>>>> at
>>>>> org.hibernate.cfg.HbmBinder.bindJoinedSubclass(HbmBinder.jav a:848)
>>>>> at
>>>>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2202)
>>>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>>>>> 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:360)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>>>
>>>>> And if I don’t qualify name i.e. us like
>>>>>
>>>>> <joined-subclass entity-name="Network" ...
>>>>>
>>>>> <joined-subclass entity-name="Network" ...
>>>>>
>>>>> !MESSAGE Duplicate class/entity mapping Network
>>>>> !STACK 0
>>>>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>>>>> mapping Network
>>>>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>>>>> at
>>>>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2204)
>>>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>>>>> 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:360)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>>>
>>>>> If I comment one of the class mapping then I get error:
>>>>>
>>>>> !MESSAGE There is more than one EClass with the same name (Network
>>>>> in EPackage model and model. A different EClassResolver should be
>>>>> used.
>>>>> !STACK 0
>>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>>> with the same name (Network in EPackage model and model. A
>>>>> different EClassResolver should be used.
>>>>> at
>>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>>
>>>>> - Parvez
>>>>>
>>>>> Martin Taal wrote:
>>>>>> Hi,
>>>>>> How did you qualify the entity name (using the QUALIFY_ENTITY_NAME
>>>>>> persistenceoption?)? Can you post the last part of the stacktrace
>>>>>> (incl. the exception message)?
>>>>>>
>>>>>> With the other issue, are you sure that the mapping xml file is
>>>>>> used? You need to tell Teneo explicitly that a mapping file should
>>>>>> be used and where it is used (using the persistenceoption:
>>>>>> PersistenceOptions.USE_MAPPING_FILE).
>>>>>>
>>>>>> Can you also post the ecore if the above does not help?
>>>>>>
>>>>>> auto-import is set on the hibernate-mapping tag in the mapping xml:
>>>>>> <hibernate-mapping
>>>>>> schema="schemaName" (1)
>>>>>> default-cascade="none|save-update" (2)
>>>>>> auto-import="true|false" (3)
>>>>>> package="package.name" (4)
>>>>>> />
>>>>>> but I would not try that just now, it should work without setting
>>>>>> auto-import explicitly.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> PC wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> As I am having more than one ecore models, it is possible that
>>>>>>> classes in different models can have the same name though in
>>>>>>> different packages.
>>>>>>>
>>>>>>> By default, hibernate file generated by Teneo does not qualify
>>>>>>> entity name with package, so that result in duplicate mapping error.
>>>>>>>
>>>>>>> I tried to qualify entities with full package name then hibernate
>>>>>>> complains that duplicate import and suggests:
>>>>>>>
>>>>>>> try using auto-import="false"
>>>>>>>
>>>>>>> So just wondering, where & how to specify this?
>>>>>>> Though during initialization I specify some hibernate properties
>>>>>>> using
>>>>>>>
>>>>>>> hbds.setHibernateProperties
>>>>>>>
>>>>>>> and I don’t see this property in Environment class of hibernate.
>>>>>>>
>>>>>>>
>>>>>>> Another issue is, if in case I don’t want to persist one of the
>>>>>>> entity i.e. more than one class with same name in different
>>>>>>> packages), then I comment out mapping for that class in hibernate
>>>>>>> file, but class still exist in package and Teneo complains that
>>>>>>> more then one EClass with same name:
>>>>>>>
>>>>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>>>>> with the same name (. . . . . A different EClassResolver should
>>>>>>> be used.
>>>>>>> at
>>>>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>>>>
>>>>>>>
>>>>>>> Any idea how to solve it?
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> - Parvez
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>


--

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: More than one class with same name [message #601736 is a reply to message #69358] Tue, 30 January 2007 11:35 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi,
How did you qualify the entity name (using the QUALIFY_ENTITY_NAME persistenceoption?)? Can you post
the last part of the stacktrace (incl. the exception message)?

With the other issue, are you sure that the mapping xml file is used? You need to tell Teneo
explicitly that a mapping file should be used and where it is used (using the persistenceoption:
PersistenceOptions.USE_MAPPING_FILE).

Can you also post the ecore if the above does not help?

auto-import is set on the hibernate-mapping tag in the mapping xml:
<hibernate-mapping
schema="schemaName" (1)
default-cascade="none|save-update" (2)
auto-import="true|false" (3)
package="package.name" (4)
/>
but I would not try that just now, it should work without setting auto-import explicitly.

gr. Martin

PC wrote:
> Hi,
>
> As I am having more than one ecore models, it is possible that classes
> in different models can have the same name though in different packages.
>
> By default, hibernate file generated by Teneo does not qualify entity
> name with package, so that result in duplicate mapping error.
>
> I tried to qualify entities with full package name then hibernate
> complains that duplicate import and suggests:
>
> try using auto-import="false"
>
> So just wondering, where & how to specify this?
> Though during initialization I specify some hibernate properties using
>
> hbds.setHibernateProperties
>
> and I don’t see this property in Environment class of hibernate.
>
>
> Another issue is, if in case I don’t want to persist one of the entity
> i.e. more than one class with same name in different packages), then I
> comment out mapping for that class in hibernate file, but class still
> exist in package and Teneo complains that more then one EClass with same
> name:
>
> java.lang.IllegalArgumentException: There is more than one EClass with
> the same name (. . . . . A different EClassResolver should be used.
> at
> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>
>
> Any idea how to solve it?
>
> Thanks.
>
> - Parvez


--

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: More than one class with same name [message #601775 is a reply to message #69379] Tue, 30 January 2007 14:50 Go to previous message
Parvez is currently offline ParvezFriend
Messages: 181
Registered: July 2009
Senior Member
Hi Martin,

I am using the option PersistenceOptions.USE_MAPPING_FILE with value "true"
but not the QUALIFY_ENTITY_NAME, I am not sure what should be its value.

In hibernate file, I have added full package name i.e.

<joined-subclass entity-name="com.pilz.pas.network.model.Network" ...
<joined-subclass entity-name="com.pilz.pas.platform.model.Network" ...


Now, I tried changing line to

<hibernate-mapping>
to
<hibernate-mapping auto-import="false">

and I get error::

!MESSAGE There is more than one EClass with the same name (Network in
EPackage model and model. A different EClassResolver should be used.
!STACK 0
java.lang.IllegalArgumentException: There is more than one EClass with
the same name (Network in EPackage model and model. A different
EClassResolver should be used.
at
org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)




If I use:
<hibernate-mapping>

then I get error:

!MESSAGE duplicate import: Network refers to both
com.pilz.pas.network.model.Network and
com.pilz.pas.platform.model.Network (try using auto-import="false")
!STACK 0
org.hibernate.DuplicateMappingException: duplicate import: Network
refers to both com.pilz.pas.network.model.Network and
com.pilz.pas.platform.model.Network (try using auto-import="false")
at org.hibernate.cfg.Mappings.addImport(Mappings.java:141)
at
org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues( HbmBinder.java:614)
at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:527)
at org.hibernate.cfg.HbmBinder.bindJoinedSubclass(HbmBinder.jav a:848)
at org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2202)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
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:360)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)




And if I don’t qualify name i.e. us like

<joined-subclass entity-name="Network" ...

<joined-subclass entity-name="Network" ...

!MESSAGE Duplicate class/entity mapping Network
!STACK 0
org.hibernate.DuplicateMappingException: Duplicate class/entity mapping
Network
at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
at org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2204)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
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:360)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)




If I comment one of the class mapping then I get error:

!MESSAGE There is more than one EClass with the same name (Network in
EPackage model and model. A different EClassResolver should be used.
!STACK 0
java.lang.IllegalArgumentException: There is more than one EClass with
the same name (Network in EPackage model and model. A different
EClassResolver should be used.
at
org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)


- Parvez




Martin Taal wrote:
> Hi,
> How did you qualify the entity name (using the QUALIFY_ENTITY_NAME
> persistenceoption?)? Can you post the last part of the stacktrace (incl.
> the exception message)?
>
> With the other issue, are you sure that the mapping xml file is used?
> You need to tell Teneo explicitly that a mapping file should be used and
> where it is used (using the persistenceoption:
> PersistenceOptions.USE_MAPPING_FILE).
>
> Can you also post the ecore if the above does not help?
>
> auto-import is set on the hibernate-mapping tag in the mapping xml:
> <hibernate-mapping
> schema="schemaName" (1)
> default-cascade="none|save-update" (2)
> auto-import="true|false" (3)
> package="package.name" (4)
> />
> but I would not try that just now, it should work without setting
> auto-import explicitly.
>
> gr. Martin
>
> PC wrote:
>> Hi,
>>
>> As I am having more than one ecore models, it is possible that classes
>> in different models can have the same name though in different packages.
>>
>> By default, hibernate file generated by Teneo does not qualify entity
>> name with package, so that result in duplicate mapping error.
>>
>> I tried to qualify entities with full package name then hibernate
>> complains that duplicate import and suggests:
>>
>> try using auto-import="false"
>>
>> So just wondering, where & how to specify this?
>> Though during initialization I specify some hibernate properties using
>>
>> hbds.setHibernateProperties
>>
>> and I don’t see this property in Environment class of hibernate.
>>
>>
>> Another issue is, if in case I don’t want to persist one of the entity
>> i.e. more than one class with same name in different packages), then I
>> comment out mapping for that class in hibernate file, but class still
>> exist in package and Teneo complains that more then one EClass with
>> same name:
>>
>> java.lang.IllegalArgumentException: There is more than one EClass with
>> the same name (. . . . . A different EClassResolver should be used.
>> at
>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>
>>
>> Any idea how to solve it?
>>
>> Thanks.
>>
>> - Parvez
>
>
Re: Teneo: More than one class with same name [message #601781 is a reply to message #69478] Tue, 30 January 2007 15:38 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Parvez,
It is described here:
http://www.elver.org/hibernate/options.html

see QUALIFY_ENTITY_NAME. If you use that then the naming issue should be solved and you don't need
to edit the xml file.
Btw, the entityname should not be set to the java classname but to the (qualified) eclass name.

See also here:
http://www.elver.org/hibernate/troubleshooting.html#org.hibe rnate.DuplicateMappingException%3A+Duplicate+class%2Fentitym apping

gr. Martin

PC wrote:
> Hi Martin,
>
> I am using the option PersistenceOptions.USE_MAPPING_FILE with value "true"
> but not the QUALIFY_ENTITY_NAME, I am not sure what should be its value.
>
> In hibernate file, I have added full package name i.e.
>
> <joined-subclass entity-name="com.pilz.pas.network.model.Network" ...
> <joined-subclass entity-name="com.pilz.pas.platform.model.Network" ...
>
>
> Now, I tried changing line to
>
> <hibernate-mapping>
> to
> <hibernate-mapping auto-import="false">
>
> and I get error::
>
> !MESSAGE There is more than one EClass with the same name (Network in
> EPackage model and model. A different EClassResolver should be used.
> !STACK 0
> java.lang.IllegalArgumentException: There is more than one EClass with
> the same name (Network in EPackage model and model. A different
> EClassResolver should be used.
> at
> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>
>
>
>
>
> If I use:
> <hibernate-mapping>
>
> then I get error:
>
> !MESSAGE duplicate import: Network refers to both
> com.pilz.pas.network.model.Network and
> com.pilz.pas.platform.model.Network (try using auto-import="false")
> !STACK 0
> org.hibernate.DuplicateMappingException: duplicate import: Network
> refers to both com.pilz.pas.network.model.Network and
> com.pilz.pas.platform.model.Network (try using auto-import="false")
> at org.hibernate.cfg.Mappings.addImport(Mappings.java:141)
> at
> org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues( HbmBinder.java:614)
>
> at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:527)
> at org.hibernate.cfg.HbmBinder.bindJoinedSubclass(HbmBinder.jav a:848)
> at
> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2202)
> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
> 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:360)
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>
>
>
>
>
> And if I don’t qualify name i.e. us like
>
> <joined-subclass entity-name="Network" ...
>
> <joined-subclass entity-name="Network" ...
>
> !MESSAGE Duplicate class/entity mapping Network
> !STACK 0
> org.hibernate.DuplicateMappingException: Duplicate class/entity mapping
> Network
> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
> at
> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2204)
> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
> 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:360)
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>
>
>
>
>
> If I comment one of the class mapping then I get error:
>
> !MESSAGE There is more than one EClass with the same name (Network in
> EPackage model and model. A different EClassResolver should be used.
> !STACK 0
> java.lang.IllegalArgumentException: There is more than one EClass with
> the same name (Network in EPackage model and model. A different
> EClassResolver should be used.
> at
> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>
> at
> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>
>
>
> - Parvez
>
>
>
>
> Martin Taal wrote:
>> Hi,
>> How did you qualify the entity name (using the QUALIFY_ENTITY_NAME
>> persistenceoption?)? Can you post the last part of the stacktrace
>> (incl. the exception message)?
>>
>> With the other issue, are you sure that the mapping xml file is used?
>> You need to tell Teneo explicitly that a mapping file should be used
>> and where it is used (using the persistenceoption:
>> PersistenceOptions.USE_MAPPING_FILE).
>>
>> Can you also post the ecore if the above does not help?
>>
>> auto-import is set on the hibernate-mapping tag in the mapping xml:
>> <hibernate-mapping
>> schema="schemaName" (1)
>> default-cascade="none|save-update" (2)
>> auto-import="true|false" (3)
>> package="package.name" (4)
>> />
>> but I would not try that just now, it should work without setting
>> auto-import explicitly.
>>
>> gr. Martin
>>
>> PC wrote:
>>> Hi,
>>>
>>> As I am having more than one ecore models, it is possible that
>>> classes in different models can have the same name though in
>>> different packages.
>>>
>>> By default, hibernate file generated by Teneo does not qualify entity
>>> name with package, so that result in duplicate mapping error.
>>>
>>> I tried to qualify entities with full package name then hibernate
>>> complains that duplicate import and suggests:
>>>
>>> try using auto-import="false"
>>>
>>> So just wondering, where & how to specify this?
>>> Though during initialization I specify some hibernate properties using
>>>
>>> hbds.setHibernateProperties
>>>
>>> and I don’t see this property in Environment class of hibernate.
>>>
>>>
>>> Another issue is, if in case I don’t want to persist one of the
>>> entity i.e. more than one class with same name in different
>>> packages), then I comment out mapping for that class in hibernate
>>> file, but class still exist in package and Teneo complains that more
>>> then one EClass with same name:
>>>
>>> java.lang.IllegalArgumentException: There is more than one EClass
>>> with the same name (. . . . . A different EClassResolver should be used.
>>> at
>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>
>>>
>>> Any idea how to solve it?
>>>
>>> Thanks.
>>>
>>> - Parvez
>>
>>


--

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: More than one class with same name [message #601785 is a reply to message #69498] Tue, 30 January 2007 16:01 Go to previous message
Parvez is currently offline ParvezFriend
Messages: 181
Registered: July 2009
Senior Member
Thanks Martin.

I will try using:

props.setProperty(PersistenceOptions.QUALIFY_ENTITY_NAME,Per sistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);

And I guess, if one hibernate file contains 2 or more classes with same
name then Teneo will use

<meta attribute="epackage">...</meta>

to find package name, is it?

- Parvez

Martin Taal wrote:
> Hi Parvez,
> It is described here:
> http://www.elver.org/hibernate/options.html
>
> see QUALIFY_ENTITY_NAME. If you use that then the naming issue should be
> solved and you don't need to edit the xml file.
> Btw, the entityname should not be set to the java classname but to the
> (qualified) eclass name.
>
> See also here:
> http://www.elver.org/hibernate/troubleshooting.html#org.hibe rnate.DuplicateMappingException%3A+Duplicate+class%2Fentitym apping
>
>
> gr. Martin
>
> PC wrote:
>> Hi Martin,
>>
>> I am using the option PersistenceOptions.USE_MAPPING_FILE with value
>> "true"
>> but not the QUALIFY_ENTITY_NAME, I am not sure what should be its value.
>>
>> In hibernate file, I have added full package name i.e.
>>
>> <joined-subclass entity-name="com.pilz.pas.network.model.Network" ...
>> <joined-subclass entity-name="com.pilz.pas.platform.model.Network" ...
>>
>>
>> Now, I tried changing line to
>>
>> <hibernate-mapping>
>> to
>> <hibernate-mapping auto-import="false">
>>
>> and I get error::
>>
>> !MESSAGE There is more than one EClass with the same name (Network in
>> EPackage model and model. A different EClassResolver should be used.
>> !STACK 0
>> java.lang.IllegalArgumentException: There is more than one EClass with
>> the same name (Network in EPackage model and model. A different
>> EClassResolver should be used.
>> at
>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>
>>
>> If I use:
>> <hibernate-mapping>
>>
>> then I get error:
>>
>> !MESSAGE duplicate import: Network refers to both
>> com.pilz.pas.network.model.Network and
>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>> !STACK 0
>> org.hibernate.DuplicateMappingException: duplicate import: Network
>> refers to both com.pilz.pas.network.model.Network and
>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>> at org.hibernate.cfg.Mappings.addImport(Mappings.java:141)
>> at
>> org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues( HbmBinder.java:614)
>>
>> at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:527)
>> at org.hibernate.cfg.HbmBinder.bindJoinedSubclass(HbmBinder.jav a:848)
>> at
>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2202)
>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>> 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:360)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>
>>
>> And if I don’t qualify name i.e. us like
>>
>> <joined-subclass entity-name="Network" ...
>>
>> <joined-subclass entity-name="Network" ...
>>
>> !MESSAGE Duplicate class/entity mapping Network
>> !STACK 0
>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>> mapping Network
>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>> at
>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2204)
>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>> 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:360)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>
>>
>>
>> If I comment one of the class mapping then I get error:
>>
>> !MESSAGE There is more than one EClass with the same name (Network in
>> EPackage model and model. A different EClassResolver should be used.
>> !STACK 0
>> java.lang.IllegalArgumentException: There is more than one EClass with
>> the same name (Network in EPackage model and model. A different
>> EClassResolver should be used.
>> at
>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>
>> at
>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>
>> - Parvez
>>
>>
>>
>> Martin Taal wrote:
>>> Hi,
>>> How did you qualify the entity name (using the QUALIFY_ENTITY_NAME
>>> persistenceoption?)? Can you post the last part of the stacktrace
>>> (incl. the exception message)?
>>>
>>> With the other issue, are you sure that the mapping xml file is used?
>>> You need to tell Teneo explicitly that a mapping file should be used
>>> and where it is used (using the persistenceoption:
>>> PersistenceOptions.USE_MAPPING_FILE).
>>>
>>> Can you also post the ecore if the above does not help?
>>>
>>> auto-import is set on the hibernate-mapping tag in the mapping xml:
>>> <hibernate-mapping
>>> schema="schemaName" (1)
>>> default-cascade="none|save-update" (2)
>>> auto-import="true|false" (3)
>>> package="package.name" (4)
>>> />
>>> but I would not try that just now, it should work without setting
>>> auto-import explicitly.
>>>
>>> gr. Martin
>>>
>>> PC wrote:
>>>> Hi,
>>>>
>>>> As I am having more than one ecore models, it is possible that
>>>> classes in different models can have the same name though in
>>>> different packages.
>>>>
>>>> By default, hibernate file generated by Teneo does not qualify
>>>> entity name with package, so that result in duplicate mapping error.
>>>>
>>>> I tried to qualify entities with full package name then hibernate
>>>> complains that duplicate import and suggests:
>>>>
>>>> try using auto-import="false"
>>>>
>>>> So just wondering, where & how to specify this?
>>>> Though during initialization I specify some hibernate properties using
>>>>
>>>> hbds.setHibernateProperties
>>>>
>>>> and I don’t see this property in Environment class of hibernate.
>>>>
>>>>
>>>> Another issue is, if in case I don’t want to persist one of the
>>>> entity i.e. more than one class with same name in different
>>>> packages), then I comment out mapping for that class in hibernate
>>>> file, but class still exist in package and Teneo complains that more
>>>> then one EClass with same name:
>>>>
>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>> with the same name (. . . . . A different EClassResolver should be
>>>> used.
>>>> at
>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>
>>>>
>>>> Any idea how to solve it?
>>>>
>>>> Thanks.
>>>>
>>>> - Parvez
>>>
>>>
>
>
Re: Teneo: More than one class with same name [message #601794 is a reply to message #69519] Tue, 30 January 2007 16:22 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Parvez,
The entity-name in the xml will be qualified. You can set the option and see how the mapping file
looks. Note you need to use the setpersistenceproperties on the hbdatastore for these options (and
setHibernateProperties for the hibernateproperties).

gr. Martin

PC wrote:
> Thanks Martin.
>
> I will try using:
>
> props.setProperty(PersistenceOptions.QUALIFY_ENTITY_NAME,Per sistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
>
>
> And I guess, if one hibernate file contains 2 or more classes with same
> name then Teneo will use
>
> <meta attribute="epackage">...</meta>
>
> to find package name, is it?
>
> - Parvez
>
> Martin Taal wrote:
>> Hi Parvez,
>> It is described here:
>> http://www.elver.org/hibernate/options.html
>>
>> see QUALIFY_ENTITY_NAME. If you use that then the naming issue should
>> be solved and you don't need to edit the xml file.
>> Btw, the entityname should not be set to the java classname but to the
>> (qualified) eclass name.
>>
>> See also here:
>> http://www.elver.org/hibernate/troubleshooting.html#org.hibe rnate.DuplicateMappingException%3A+Duplicate+class%2Fentitym apping
>>
>>
>> gr. Martin
>>
>> PC wrote:
>>> Hi Martin,
>>>
>>> I am using the option PersistenceOptions.USE_MAPPING_FILE with value
>>> "true"
>>> but not the QUALIFY_ENTITY_NAME, I am not sure what should be its value.
>>>
>>> In hibernate file, I have added full package name i.e.
>>>
>>> <joined-subclass entity-name="com.pilz.pas.network.model.Network" ...
>>> <joined-subclass entity-name="com.pilz.pas.platform.model.Network" ...
>>>
>>>
>>> Now, I tried changing line to
>>>
>>> <hibernate-mapping>
>>> to
>>> <hibernate-mapping auto-import="false">
>>>
>>> and I get error::
>>>
>>> !MESSAGE There is more than one EClass with the same name (Network in
>>> EPackage model and model. A different EClassResolver should be used.
>>> !STACK 0
>>> java.lang.IllegalArgumentException: There is more than one EClass
>>> with the same name (Network in EPackage model and model. A different
>>> EClassResolver should be used.
>>> at
>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>
>>> If I use:
>>> <hibernate-mapping>
>>>
>>> then I get error:
>>>
>>> !MESSAGE duplicate import: Network refers to both
>>> com.pilz.pas.network.model.Network and
>>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>>> !STACK 0
>>> org.hibernate.DuplicateMappingException: duplicate import: Network
>>> refers to both com.pilz.pas.network.model.Network and
>>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>>> at org.hibernate.cfg.Mappings.addImport(Mappings.java:141)
>>> at
>>> org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues( HbmBinder.java:614)
>>>
>>> at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:527)
>>> at
>>> org.hibernate.cfg.HbmBinder.bindJoinedSubclass(HbmBinder.jav a:848)
>>> at
>>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2202)
>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>>> 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:360)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>
>>> And if I don’t qualify name i.e. us like
>>>
>>> <joined-subclass entity-name="Network" ...
>>>
>>> <joined-subclass entity-name="Network" ...
>>>
>>> !MESSAGE Duplicate class/entity mapping Network
>>> !STACK 0
>>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>>> mapping Network
>>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>>> at
>>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2204)
>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>>> 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:360)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>
>>>
>>> If I comment one of the class mapping then I get error:
>>>
>>> !MESSAGE There is more than one EClass with the same name (Network in
>>> EPackage model and model. A different EClassResolver should be used.
>>> !STACK 0
>>> java.lang.IllegalArgumentException: There is more than one EClass
>>> with the same name (Network in EPackage model and model. A different
>>> EClassResolver should be used.
>>> at
>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>
>>> - Parvez
>>>
>>>
>>> Martin Taal wrote:
>>>> Hi,
>>>> How did you qualify the entity name (using the QUALIFY_ENTITY_NAME
>>>> persistenceoption?)? Can you post the last part of the stacktrace
>>>> (incl. the exception message)?
>>>>
>>>> With the other issue, are you sure that the mapping xml file is
>>>> used? You need to tell Teneo explicitly that a mapping file should
>>>> be used and where it is used (using the persistenceoption:
>>>> PersistenceOptions.USE_MAPPING_FILE).
>>>>
>>>> Can you also post the ecore if the above does not help?
>>>>
>>>> auto-import is set on the hibernate-mapping tag in the mapping xml:
>>>> <hibernate-mapping
>>>> schema="schemaName" (1)
>>>> default-cascade="none|save-update" (2)
>>>> auto-import="true|false" (3)
>>>> package="package.name" (4)
>>>> />
>>>> but I would not try that just now, it should work without setting
>>>> auto-import explicitly.
>>>>
>>>> gr. Martin
>>>>
>>>> PC wrote:
>>>>> Hi,
>>>>>
>>>>> As I am having more than one ecore models, it is possible that
>>>>> classes in different models can have the same name though in
>>>>> different packages.
>>>>>
>>>>> By default, hibernate file generated by Teneo does not qualify
>>>>> entity name with package, so that result in duplicate mapping error.
>>>>>
>>>>> I tried to qualify entities with full package name then hibernate
>>>>> complains that duplicate import and suggests:
>>>>>
>>>>> try using auto-import="false"
>>>>>
>>>>> So just wondering, where & how to specify this?
>>>>> Though during initialization I specify some hibernate properties using
>>>>>
>>>>> hbds.setHibernateProperties
>>>>>
>>>>> and I don’t see this property in Environment class of hibernate.
>>>>>
>>>>>
>>>>> Another issue is, if in case I don’t want to persist one of the
>>>>> entity i.e. more than one class with same name in different
>>>>> packages), then I comment out mapping for that class in hibernate
>>>>> file, but class still exist in package and Teneo complains that
>>>>> more then one EClass with same name:
>>>>>
>>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>>> with the same name (. . . . . A different EClassResolver should be
>>>>> used.
>>>>> at
>>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>>
>>>>>
>>>>> Any idea how to solve it?
>>>>>
>>>>> Thanks.
>>>>>
>>>>> - Parvez
>>>>
>>>>
>>
>>


--

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: More than one class with same name [message #601800 is a reply to message #69539] Tue, 30 January 2007 17:17 Go to previous message
Parvez is currently offline ParvezFriend
Messages: 181
Registered: July 2009
Senior Member
Sorry Martin, I "think" may be I got confused now about how
QUALIFY_ENTITY_NAME is going to work.

It looks to me that this option may not work for me, because I generate
hibernate file before running the application i.e. by right clicking on
ecore file and I use PersistenceOptions.USE_MAPPING_FILE, "true".
So I guess that won’t change hibernate file, but may be it can update
the loaded xml data. I will try it and will update accordingly.

- Parvez

Martin Taal wrote:
> Hi Parvez,
> The entity-name in the xml will be qualified. You can set the option and
> see how the mapping file looks. Note you need to use the
> setpersistenceproperties on the hbdatastore for these options (and
> setHibernateProperties for the hibernateproperties).
>
> gr. Martin
>
> PC wrote:
>> Thanks Martin.
>>
>> I will try using:
>>
>> props.setProperty(PersistenceOptions.QUALIFY_ENTITY_NAME,Per sistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
>>
>>
>> And I guess, if one hibernate file contains 2 or more classes with
>> same name then Teneo will use
>>
>> <meta attribute="epackage">...</meta>
>>
>> to find package name, is it?
>>
>> - Parvez
>>
>> Martin Taal wrote:
>>> Hi Parvez,
>>> It is described here:
>>> http://www.elver.org/hibernate/options.html
>>>
>>> see QUALIFY_ENTITY_NAME. If you use that then the naming issue should
>>> be solved and you don't need to edit the xml file.
>>> Btw, the entityname should not be set to the java classname but to
>>> the (qualified) eclass name.
>>>
>>> See also here:
>>> http://www.elver.org/hibernate/troubleshooting.html#org.hibe rnate.DuplicateMappingException%3A+Duplicate+class%2Fentitym apping
>>>
>>>
>>> gr. Martin
>>>
>>> PC wrote:
>>>> Hi Martin,
>>>>
>>>> I am using the option PersistenceOptions.USE_MAPPING_FILE with value
>>>> "true"
>>>> but not the QUALIFY_ENTITY_NAME, I am not sure what should be its
>>>> value.
>>>>
>>>> In hibernate file, I have added full package name i.e.
>>>>
>>>> <joined-subclass entity-name="com.pilz.pas.network.model.Network" ...
>>>> <joined-subclass entity-name="com.pilz.pas.platform.model.Network" ...
>>>>
>>>>
>>>> Now, I tried changing line to
>>>>
>>>> <hibernate-mapping>
>>>> to
>>>> <hibernate-mapping auto-import="false">
>>>>
>>>> and I get error::
>>>>
>>>> !MESSAGE There is more than one EClass with the same name (Network
>>>> in EPackage model and model. A different EClassResolver should be used.
>>>> !STACK 0
>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>> with the same name (Network in EPackage model and model. A different
>>>> EClassResolver should be used.
>>>> at
>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>
>>>> If I use:
>>>> <hibernate-mapping>
>>>>
>>>> then I get error:
>>>>
>>>> !MESSAGE duplicate import: Network refers to both
>>>> com.pilz.pas.network.model.Network and
>>>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>>>> !STACK 0
>>>> org.hibernate.DuplicateMappingException: duplicate import: Network
>>>> refers to both com.pilz.pas.network.model.Network and
>>>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>>>> at org.hibernate.cfg.Mappings.addImport(Mappings.java:141)
>>>> at
>>>> org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues( HbmBinder.java:614)
>>>>
>>>> at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:527)
>>>> at
>>>> org.hibernate.cfg.HbmBinder.bindJoinedSubclass(HbmBinder.jav a:848)
>>>> at
>>>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2202)
>>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>>>> 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:360)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>>
>>>> And if I don’t qualify name i.e. us like
>>>>
>>>> <joined-subclass entity-name="Network" ...
>>>>
>>>> <joined-subclass entity-name="Network" ...
>>>>
>>>> !MESSAGE Duplicate class/entity mapping Network
>>>> !STACK 0
>>>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>>>> mapping Network
>>>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>>>> at
>>>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2204)
>>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>>>> 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:360)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>>
>>>> If I comment one of the class mapping then I get error:
>>>>
>>>> !MESSAGE There is more than one EClass with the same name (Network
>>>> in EPackage model and model. A different EClassResolver should be used.
>>>> !STACK 0
>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>> with the same name (Network in EPackage model and model. A different
>>>> EClassResolver should be used.
>>>> at
>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>
>>>> at
>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>
>>>> - Parvez
>>>>
>>>> Martin Taal wrote:
>>>>> Hi,
>>>>> How did you qualify the entity name (using the QUALIFY_ENTITY_NAME
>>>>> persistenceoption?)? Can you post the last part of the stacktrace
>>>>> (incl. the exception message)?
>>>>>
>>>>> With the other issue, are you sure that the mapping xml file is
>>>>> used? You need to tell Teneo explicitly that a mapping file should
>>>>> be used and where it is used (using the persistenceoption:
>>>>> PersistenceOptions.USE_MAPPING_FILE).
>>>>>
>>>>> Can you also post the ecore if the above does not help?
>>>>>
>>>>> auto-import is set on the hibernate-mapping tag in the mapping xml:
>>>>> <hibernate-mapping
>>>>> schema="schemaName" (1)
>>>>> default-cascade="none|save-update" (2)
>>>>> auto-import="true|false" (3)
>>>>> package="package.name" (4)
>>>>> />
>>>>> but I would not try that just now, it should work without setting
>>>>> auto-import explicitly.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> PC wrote:
>>>>>> Hi,
>>>>>>
>>>>>> As I am having more than one ecore models, it is possible that
>>>>>> classes in different models can have the same name though in
>>>>>> different packages.
>>>>>>
>>>>>> By default, hibernate file generated by Teneo does not qualify
>>>>>> entity name with package, so that result in duplicate mapping error.
>>>>>>
>>>>>> I tried to qualify entities with full package name then hibernate
>>>>>> complains that duplicate import and suggests:
>>>>>>
>>>>>> try using auto-import="false"
>>>>>>
>>>>>> So just wondering, where & how to specify this?
>>>>>> Though during initialization I specify some hibernate properties
>>>>>> using
>>>>>>
>>>>>> hbds.setHibernateProperties
>>>>>>
>>>>>> and I don’t see this property in Environment class of hibernate.
>>>>>>
>>>>>>
>>>>>> Another issue is, if in case I don’t want to persist one of the
>>>>>> entity i.e. more than one class with same name in different
>>>>>> packages), then I comment out mapping for that class in hibernate
>>>>>> file, but class still exist in package and Teneo complains that
>>>>>> more then one EClass with same name:
>>>>>>
>>>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>>>> with the same name (. . . . . A different EClassResolver should be
>>>>>> used.
>>>>>> at
>>>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>>>
>>>>>>
>>>>>> Any idea how to solve it?
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> - Parvez
>>>>>
>>>>>
>>>
>>>
>
>
Re: Teneo: More than one class with same name [message #601806 is a reply to message #69559] Tue, 30 January 2007 17:24 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Updating the loaded xml will not work I think (afaik).

You can also write a small java app (with just a static main method) which calls
HbHelper.INSTANCE.generateMapping to generate a mapping file. This method allows you to pass the
persistenceproperties.

gr. Martin

PC wrote:
> Sorry Martin, I "think" may be I got confused now about how
> QUALIFY_ENTITY_NAME is going to work.
>
> It looks to me that this option may not work for me, because I generate
> hibernate file before running the application i.e. by right clicking on
> ecore file and I use PersistenceOptions.USE_MAPPING_FILE, "true".
> So I guess that won’t change hibernate file, but may be it can update
> the loaded xml data. I will try it and will update accordingly.
>
> - Parvez
>
> Martin Taal wrote:
>> Hi Parvez,
>> The entity-name in the xml will be qualified. You can set the option
>> and see how the mapping file looks. Note you need to use the
>> setpersistenceproperties on the hbdatastore for these options (and
>> setHibernateProperties for the hibernateproperties).
>>
>> gr. Martin
>>
>> PC wrote:
>>> Thanks Martin.
>>>
>>> I will try using:
>>>
>>> props.setProperty(PersistenceOptions.QUALIFY_ENTITY_NAME,Per sistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);
>>>
>>>
>>> And I guess, if one hibernate file contains 2 or more classes with
>>> same name then Teneo will use
>>>
>>> <meta attribute="epackage">...</meta>
>>>
>>> to find package name, is it?
>>>
>>> - Parvez
>>>
>>> Martin Taal wrote:
>>>> Hi Parvez,
>>>> It is described here:
>>>> http://www.elver.org/hibernate/options.html
>>>>
>>>> see QUALIFY_ENTITY_NAME. If you use that then the naming issue
>>>> should be solved and you don't need to edit the xml file.
>>>> Btw, the entityname should not be set to the java classname but to
>>>> the (qualified) eclass name.
>>>>
>>>> See also here:
>>>> http://www.elver.org/hibernate/troubleshooting.html#org.hibe rnate.DuplicateMappingException%3A+Duplicate+class%2Fentitym apping
>>>>
>>>>
>>>> gr. Martin
>>>>
>>>> PC wrote:
>>>>> Hi Martin,
>>>>>
>>>>> I am using the option PersistenceOptions.USE_MAPPING_FILE with
>>>>> value "true"
>>>>> but not the QUALIFY_ENTITY_NAME, I am not sure what should be its
>>>>> value.
>>>>>
>>>>> In hibernate file, I have added full package name i.e.
>>>>>
>>>>> <joined-subclass entity-name="com.pilz.pas.network.model.Network" ...
>>>>> <joined-subclass entity-name="com.pilz.pas.platform.model.Network" ...
>>>>>
>>>>>
>>>>> Now, I tried changing line to
>>>>>
>>>>> <hibernate-mapping>
>>>>> to
>>>>> <hibernate-mapping auto-import="false">
>>>>>
>>>>> and I get error::
>>>>>
>>>>> !MESSAGE There is more than one EClass with the same name (Network
>>>>> in EPackage model and model. A different EClassResolver should be
>>>>> used.
>>>>> !STACK 0
>>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>>> with the same name (Network in EPackage model and model. A
>>>>> different EClassResolver should be used.
>>>>> at
>>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>>
>>>>> If I use:
>>>>> <hibernate-mapping>
>>>>>
>>>>> then I get error:
>>>>>
>>>>> !MESSAGE duplicate import: Network refers to both
>>>>> com.pilz.pas.network.model.Network and
>>>>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>>>>> !STACK 0
>>>>> org.hibernate.DuplicateMappingException: duplicate import: Network
>>>>> refers to both com.pilz.pas.network.model.Network and
>>>>> com.pilz.pas.platform.model.Network (try using auto-import="false")
>>>>> at org.hibernate.cfg.Mappings.addImport(Mappings.java:141)
>>>>> at
>>>>> org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues( HbmBinder.java:614)
>>>>>
>>>>> at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:527)
>>>>> at
>>>>> org.hibernate.cfg.HbmBinder.bindJoinedSubclass(HbmBinder.jav a:848)
>>>>> at
>>>>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2202)
>>>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>>>>> 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:360)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>>>
>>>>> And if I don’t qualify name i.e. us like
>>>>>
>>>>> <joined-subclass entity-name="Network" ...
>>>>>
>>>>> <joined-subclass entity-name="Network" ...
>>>>>
>>>>> !MESSAGE Duplicate class/entity mapping Network
>>>>> !STACK 0
>>>>> org.hibernate.DuplicateMappingException: Duplicate class/entity
>>>>> mapping Network
>>>>> at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
>>>>> at
>>>>> org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.j ava:2204)
>>>>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
>>>>> 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:360)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:156)
>>>>>
>>>>> If I comment one of the class mapping then I get error:
>>>>>
>>>>> !MESSAGE There is more than one EClass with the same name (Network
>>>>> in EPackage model and model. A different EClassResolver should be
>>>>> used.
>>>>> !STACK 0
>>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>>> with the same name (Network in EPackage model and model. A
>>>>> different EClassResolver should be used.
>>>>> at
>>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>>
>>>>> - Parvez
>>>>>
>>>>> Martin Taal wrote:
>>>>>> Hi,
>>>>>> How did you qualify the entity name (using the QUALIFY_ENTITY_NAME
>>>>>> persistenceoption?)? Can you post the last part of the stacktrace
>>>>>> (incl. the exception message)?
>>>>>>
>>>>>> With the other issue, are you sure that the mapping xml file is
>>>>>> used? You need to tell Teneo explicitly that a mapping file should
>>>>>> be used and where it is used (using the persistenceoption:
>>>>>> PersistenceOptions.USE_MAPPING_FILE).
>>>>>>
>>>>>> Can you also post the ecore if the above does not help?
>>>>>>
>>>>>> auto-import is set on the hibernate-mapping tag in the mapping xml:
>>>>>> <hibernate-mapping
>>>>>> schema="schemaName" (1)
>>>>>> default-cascade="none|save-update" (2)
>>>>>> auto-import="true|false" (3)
>>>>>> package="package.name" (4)
>>>>>> />
>>>>>> but I would not try that just now, it should work without setting
>>>>>> auto-import explicitly.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> PC wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> As I am having more than one ecore models, it is possible that
>>>>>>> classes in different models can have the same name though in
>>>>>>> different packages.
>>>>>>>
>>>>>>> By default, hibernate file generated by Teneo does not qualify
>>>>>>> entity name with package, so that result in duplicate mapping error.
>>>>>>>
>>>>>>> I tried to qualify entities with full package name then hibernate
>>>>>>> complains that duplicate import and suggests:
>>>>>>>
>>>>>>> try using auto-import="false"
>>>>>>>
>>>>>>> So just wondering, where & how to specify this?
>>>>>>> Though during initialization I specify some hibernate properties
>>>>>>> using
>>>>>>>
>>>>>>> hbds.setHibernateProperties
>>>>>>>
>>>>>>> and I don’t see this property in Environment class of hibernate.
>>>>>>>
>>>>>>>
>>>>>>> Another issue is, if in case I don’t want to persist one of the
>>>>>>> entity i.e. more than one class with same name in different
>>>>>>> packages), then I comment out mapping for that class in hibernate
>>>>>>> file, but class still exist in package and Teneo complains that
>>>>>>> more then one EClass with same name:
>>>>>>>
>>>>>>> java.lang.IllegalArgumentException: There is more than one EClass
>>>>>>> with the same name (. . . . . A different EClassResolver should
>>>>>>> be used.
>>>>>>> at
>>>>>>> org.eclipse.emf.teneo.ecore.DefaultEClassNameStrategy.toECla ss(DefaultEClassNameStrategy.java:60)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:812)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.setRefersToOfSup ers(HbDataStore.java:826)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.computeReferers( HbDataStore.java:800)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:163)
>>>>>>>
>>>>>>>
>>>>>>> Any idea how to solve it?
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> - Parvez
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>


--

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
Previous Topic:[OCL] String Operations
Next Topic:teneo - when will EMF2.3 (i.e., the Java 5.0 features) be supported?
Goto Forum:
  


Current Time: Fri Apr 19 06:34:32 GMT 2024

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

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

Back to the top