Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Strange DuplicateMappingException with Teneo
Strange DuplicateMappingException with Teneo [message #596128] Fri, 24 November 2006 14:01
Sascha Theves is currently offline Sascha ThevesFriend
Messages: 39
Registered: July 2009
Member
Hi all,

I am working on an application using EMF with the teneo project. I
followed the quick start guide on the elver.org site and it all works
fine for me. But when I am using my own EMF model, I messed up with an
DuplicateMappingException while trying to initialize the db scheme:

------------------------------------------------------------ -
org.hibernate.DuplicateMappingException: duplicate import: Error refers
to both ...context.Error and ...flow.Error (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.bindSubclass(HbmBinder.java:809)
at org.hibernate.cfg.HbmBinder.handleSubclass(HbmBinder.java:22 10)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:149)
at org.hibernate.cfg.Configuration.add(Configuration.java:669)
at org.hibernate.cfg.Configuration.addXML(Configuration.java:44 0)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.mapModel(HbDataS tore.java:360)
at
org.eclipse.emf.teneo.hibernate.HbDataStore.initialize(HbDat aStore.java:155)
at ...DataStoreManager.initDataStore(DataStoreManager.java:73)
at ...TestSomething.testSomething(TestSomething.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
------------------------------------------------------------ -

The strange thing is that I used the property
PersistenceOptions.QUALIFY_ENTITY_NAME to get an prefix for the mapped
classes but anyway I get the exception! Here is my code wich I use to
init the db scheme:

------------------------------------------------------------ -
// Set the database information, Environment is
org.hibernate.cfg.Environment
final Properties props = new Properties();
props.setProperty(Environment.DRIVER, db_driver);
props.setProperty(Environment.USER, db_user);
props.setProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/"
+ db_name);
props.setProperty(Environment.PASS, db_pass);
props.setProperty(Environment.DIALECT,
org.hibernate.dialect.MySQLInnoDBDialect.class.getName());

// persistance properties
final Properties persistanceProps = new Properties();
// HERE IS THE THE QUALIFY_ENTITY_NAME OPTION
persistanceProps.setProperty(PersistenceOptions.QUALIFY_ENTI TY_NAME,
PersistenceOptions.QUALIFY_ENTITY_NAME_NSPREFIX);

// create the HbDataStore
HbDataStore hbds =
HbHelper.INSTANCE.createRegisterDataStore(hb_datastore);

// sets its epackages stored in this datastore
hbds.setEPackages(new EPackage[] {BasePackage.eINSTANCE,
RulePackage.eINSTANCE, FlowPackage.eINSTANCE,
ContextPackage.eINSTANCE, BindingPackage.eINSTANCE,
EnvironmentPackage.eINSTANCE, ExpressionPackage.eINSTANCE,
MessagePackage.eINSTANCE, TestPackage.eINSTANCE,
WorkflowPackage.eINSTANCE});

// set the relational database to use and other properties
// to set Teneo specific options call hbds.setPersistenceProperties
hbds.setHibernateProperties(props);

// HERE ARE THE PROPS TO SET
hbds.setPersistenceProperties(persistanceProps);


// initialize, also creates the database tables
hbds.initialize();
------------------------------------------------------------ -

Here is the snippet of the hibernate mapping file which were generated
for my EMF Model by teneo:

....
<subclass entity-name="...context.Error" abstract="false" lazy="false"
extends="...context.Class" discriminator-value="Error">
<meta attribute="eclassName">Error</meta>
<meta attribute="epackage">http:///.../context.ecore</meta>
</subclass>
....
<subclass entity-name="...base.flow.Error" abstract="false" lazy="false"
extends="de.visualrules.base.flow.Statement" discriminator-value="Error">
<meta attribute="eclassName">Error</meta>
<meta attribute="epackage">http:///.../base/flow.ecore</meta>
<many-to-one name="message"
entity-name="...base.expression.Expression" cascade="all" lazy="false"
insert="true" update="true" not-null="false">
<column not-null="false" unique="false" name="`expression_message_id`"/>
</many-to-one>
</subclass>
....

I think the problem is that the value of 'discriminator-value' is the
same for the '...flow.Error' class and the '...context.Error' class. I
havent found a property that influences this behavior. For me it is not
clear why teneo explicitly set the attribute 'discriminator-value'
because Hibernate uses the fully qulified class name per default (I think).

Are there any solutions for this problem?

thanks in advance, sascha
Previous Topic:Can Validation handle inter-model constraints?
Next Topic:teneo - two different hibernate databases in one ResourceSet
Goto Forum:
  


Current Time: Thu Apr 25 09:17:57 GMT 2024

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

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

Back to the top