[CDO] Duplicate annotation using CDO Hibernate [message #729462] |
Mon, 26 September 2011 09:11 |
Missing name Missing name Messages: 17 Registered: September 2011 |
Junior Member |
|
|
Hello.
I am testing CDO Hibernate over MySQL with the JDTAST metamodel provided by the Atlanmod research group, which can be downloaded here: www.sciences.univ-nantes.fr/lina/atl/www/GraBaTs2009/JDTAST.ecore.
I have generated the EMF plugin for the metamodel. The problem is that, when I try to store a dynamic model into CDO Hibernate (version 4.0), it gives an Hibernate duplicate mapping error (see the end of the post). This error prevents me to re-start the CDO server unless I manually delete the JDTST packages from the database.
My test code is based on the BaseTest class from the org.eclipse.emf.cdo.examples.hibernate.client plugin, which works fine. I suppose that the problem is in the Hibernate mapping that is automatically generated when the metamodel is registered in the repository, but I have generated a Hibernate mapping using the GenerateHBMTest class which has no duplicated mappings.
How can I solve this problem? The JDTST metamodel has worked fine for me many times and I prefer not to modify it because its instances are huge and it would be very cumbersome.
My test code:
static public void testFullSave(ResourceSet rs, String sourceFile, String resourceName, boolean legacyMode) {
EPackage.Registry.INSTANCE.put(CorePackage.eNS_URI, CorePackage.eINSTANCE);
EPackage.Registry.INSTANCE.put(PrimitiveTypesPackage.eNS_URI, PrimitiveTypesPackage.eINSTANCE);
EPackage.Registry.INSTANCE.put(DOMPackage.eNS_URI, DOMPackage.eINSTANCE);
Resource r = rs
.getResource(URI.createFileURI(new File(sourceFile)
.getAbsolutePath()), true);
List<EObject> roots = r.getContents();
CDOSessionConfiguration sessionConfiguration = initialize();
if (legacyMode) {
CDOUtil.setLegacyModeDefault(true);
}
CDOSession session = openSession(sessionConfiguration);
long l = System.currentTimeMillis();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.getOrCreateResource(resourceName); //$NON-NLS-1$
resource.getContents().clear();
resource.getContents().addAll(roots);
try {
transaction.commit();
System.err.println("FULL SAVE TIME: " + (System.currentTimeMillis() - l));
} catch (CommitException e) {
e.printStackTrace();
}
}
The exception:
org.eclipse.emf.cdo.util.CommitException: Rollback in HibernateStore: org.hibernate.InvalidMappingException: Could not parse mapping document from string XML String
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3951)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3940)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3928)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1368)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1826)
at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore.getHibernateSessionFactory(HibernateStore.java:256)
at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.beginHibernateSession(HibernateStoreAccessor.java:192)
at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.getNewHibernateSession(HibernateStoreAccessor.java:289)
at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.doWrite(HibernateStoreAccessor.java:655)
at org.eclipse.emf.cdo.spi.server.StoreAccessorBase.write(StoreAccessorBase.java:149)
at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.write(TransactionCommitContext.java:425)
at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:42)
at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:1)
at org.eclipse.net4j.util.om.monitor.ProgressDistributor.run(ProgressDistributor.java:96)
at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicatingCommit(CommitTransactionIndication.java:244)
at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicating(CommitTransactionIndication.java:92)
at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndicationWithMonitoring.indicating(CDOServerIndicationWithMonitoring.java:109)
at org.eclipse.net4j.signal.IndicationWithMonitoring.indicating(IndicationWithMonitoring.java:84)
at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedInput(IndicationWithResponse.java:90)
at org.eclipse.net4j.signal.Signal.doInput(Signal.java:326)
at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:63)
at org.eclipse.net4j.signal.IndicationWithMonitoring.execute(IndicationWithMonitoring.java:63)
at org.eclipse.net4j.signal.Signal.runSync(Signal.java:251)
at org.eclipse.net4j.signal.Signal.run(Signal.java:147)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping Annotation
at org.hibernate.cfg.Configuration$MappingsImpl.addClass(Configuration.java:3121)
at org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.java:2307)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:183)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3948)
... 26 more
at org.eclipse.emf.internal.cdo.transaction.CDOSingleTransactionStrategyImpl.commit(CDOSingleTransactionStrategyImpl.java:94)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1058)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1078)
at org.eclipse.emf.cdo.examples.hibernate.client.BaseTest.testFullSave(BaseTest.java:179)
at org.eclipse.emf.cdo.examples.hibernate.client.BaseTest.main(BaseTest.java:115)
Thanks in advance.
|
|
|
Re: [CDO] Duplicate annotation using CDO Hibernate [message #729490 is a reply to message #729462] |
Mon, 26 September 2011 10:06 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi,
My guess is that different eclasses are mapped using the same entity name.
You can solve this by setting an @Entity annotation on one of the duplicate eclasses. See here how to set annotations in
the model:
http://wiki.eclipse.org/Teneo/Hibernate#Model_Relational_Mapping_with_EJB3.2FJPA_Annotations
Or you can tell Teneo to use a qualifying naming strategy which solves it for all eclasses in one step (but you have to
use qualified entity names in any hql you are using):
http://wiki.eclipse.org/CDO_Hibernate_Store_Model_Relational_Mapping#Teneo_Extensions
http://wiki.eclipse.org/Teneo/Hibernate/Extensions#EntityNameStrategy_ExtensionPoint_.28org.eclipse.emf.teneo.mapping.strategy.EntityNameStrategy.29
gr. Martin
On 09/26/2011 11:11 AM, inbasswetrust wrote:
> Hello.
>
> I am testing CDO Hibernate over MySQL with the JDTAST metamodel provided by the Atlanmod research group, which can be
> downloaded here: www.sciences.univ-nantes.fr/lina/atl/www/GraBaTs2009/JDTAST.ecore.
>
> I have generated the EMF plugin for the metamodel. The problem is that, when I try to store a dynamic model into CDO
> Hibernate (version 4.0), it gives an Hibernate duplicate mapping error (see the end of the post). This error prevents me
> to re-start the CDO server unless I manually delete the JDTST packages from the database.
>
> My test code is based on the BaseTest class from the org.eclipse.emf.cdo.examples.hibernate.client plugin, which works
> fine. I suppose that the problem is in the Hibernate mapping that is automatically generated when the metamodel is
> registered in the repository, but I have generated a Hibernate mapping using the GenerateHBMTest class which has no
> duplicated mappings.
>
> How can I solve this problem? The JDTST metamodel has worked fine for me many times and I prefer not to modify it
> because its instances are huge and it would be very cumbersome.
>
> My test code:
>
>
> static public void testFullSave(ResourceSet rs, String sourceFile, String resourceName, boolean legacyMode) {
> EPackage.Registry.INSTANCE.put(CorePackage.eNS_URI, CorePackage.eINSTANCE);
> EPackage.Registry.INSTANCE.put(PrimitiveTypesPackage.eNS_URI, PrimitiveTypesPackage.eINSTANCE);
> EPackage.Registry.INSTANCE.put(DOMPackage.eNS_URI, DOMPackage.eINSTANCE);
>
> Resource r = rs
> .getResource(URI.createFileURI(new File(sourceFile)
> .getAbsolutePath()), true);
> List<EObject> roots = r.getContents();
>
> CDOSessionConfiguration sessionConfiguration = initialize();
> if (legacyMode) {
> CDOUtil.setLegacyModeDefault(true);
> }
>
> CDOSession session = openSession(sessionConfiguration);
> long l = System.currentTimeMillis();
> CDOTransaction transaction = session.openTransaction();
> CDOResource resource = transaction.getOrCreateResource(resourceName); //$NON-NLS-1$
> resource.getContents().clear();
>
> resource.getContents().addAll(roots);
> try {
> transaction.commit();
> System.err.println("FULL SAVE TIME: " + (System.currentTimeMillis() - l));
> } catch (CommitException e) {
> e.printStackTrace();
> }
> }
>
>
>
> The exception:
>
>
> org.eclipse.emf.cdo.util.CommitException: Rollback in HibernateStore: org.hibernate.InvalidMappingException: Could not
> parse mapping document from string XML String
> at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3951)
> at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3940)
> at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3928)
> at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1368)
> at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1826)
> at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore.getHibernateSessionFactory(HibernateStore.java:256)
> at
> org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.beginHibernateSession(HibernateStoreAccessor.java:192)
> at
> org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.getNewHibernateSession(HibernateStoreAccessor.java:289)
>
> at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.doWrite(HibernateStoreAccessor.java:655)
> at org.eclipse.emf.cdo.spi.server.StoreAccessorBase.write(StoreAccessorBase.java:149)
> at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.write(TransactionCommitContext.java:425)
> at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:42)
> at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:1)
> at org.eclipse.net4j.util.om.monitor.ProgressDistributor.run(ProgressDistributor.java:96)
> at
> org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicatingCommit(CommitTransactionIndication.java:244)
>
> at
> org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicating(CommitTransactionIndication.java:92)
>
> at
> org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndicationWithMonitoring.indicating(CDOServerIndicationWithMonitoring.java:109)
>
> at org.eclipse.net4j.signal.IndicationWithMonitoring.indicating(IndicationWithMonitoring.java:84)
> at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedInput(IndicationWithResponse.java:90)
> at org.eclipse.net4j.signal.Signal.doInput(Signal.java:326)
> at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:63)
> at org.eclipse.net4j.signal.IndicationWithMonitoring.execute(IndicationWithMonitoring.java:63)
> at org.eclipse.net4j.signal.Signal.runSync(Signal.java:251)
> at org.eclipse.net4j.signal.Signal.run(Signal.java:147)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
> Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping Annotation
> at org.hibernate.cfg.Configuration$MappingsImpl.addClass(Configuration.java:3121)
> at org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.java:2307)
> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:183)
> at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3948)
> ... 26 more
>
> at
> org.eclipse.emf.internal.cdo.transaction.CDOSingleTransactionStrategyImpl.commit(CDOSingleTransactionStrategyImpl.java:94)
> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1058)
> at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:1078)
> at org.eclipse.emf.cdo.examples.hibernate.client.BaseTest.testFullSave(BaseTest.java:179)
> at org.eclipse.emf.cdo.examples.hibernate.client.BaseTest.main(BaseTest.java:115)
>
>
> Thanks in advance.
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
|
Powered by
FUDForum. Page generated in 0.05937 seconds