Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 330855

Summary: Using HbEntityDataStore causes org.hibernate.MappingException: Unknown entity:...
Product: [Modeling] EMF Reporter: Flavio Donze <flavio.donze>
Component: TeneoAssignee: Martin Taal <mtaal>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Modified QuickStart.java none

Description Flavio Donze CLA 2010-11-22 16:11:09 EST
Build Identifier: 1.1.2.v201011151542

Using HbEntityDataStore instead of HbDataStore causes the following exception after Teneo uses Hibernate 3.6:

Exception in thread "main" javax.persistence.PersistenceException: Unable to build EntityManagerFactory
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:911)
	at org.eclipse.emf.teneo.hibernate.HbEntityDataStore.buildEntityManagerFactory(HbEntityDataStore.java:242)
	at org.eclipse.emf.teneo.hibernate.HbEntityDataStore.initialize(HbEntityDataStore.java:116)
	at org.eclipse.emf.teneo.hibernate.examples.QuickStart.doQuickStart(QuickStart.java:101)
	at org.eclipse.emf.teneo.hibernate.examples.QuickStart.main(QuickStart.java:49)
Caused by: org.hibernate.MappingException: Unknown entity: org.eclipse.emf.teneo.hibernate.examples.extlibrary.impl.ItemImpl
	at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:691)
	at org.hibernate.ejb.metamodel.AttributeFactory.getDeclarerEntityMetamodel(AttributeFactory.java:242)
	at org.hibernate.ejb.metamodel.AttributeFactory.access$600(AttributeFactory.java:66)
	at org.hibernate.ejb.metamodel.AttributeFactory$4.resolveMember(AttributeFactory.java:955)
	at org.hibernate.ejb.metamodel.AttributeFactory.determineAttributeMetadata(AttributeFactory.java:444)
	at org.hibernate.ejb.metamodel.AttributeFactory.buildAttribute(AttributeFactory.java:93)
	at org.hibernate.ejb.metamodel.MetadataContext.wrapUp(MetadataContext.java:183)
	at org.hibernate.ejb.metamodel.MetamodelImpl.buildMetamodel(MetamodelImpl.java:66)
	at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
	... 4 more

Reproducible: Always
Comment 1 Flavio Donze CLA 2010-11-22 16:15:54 EST
Created attachment 183606 [details]
Modified QuickStart.java

Martin, It's actually pointless to attach a test model since the error occurs even with a small model having only one object with only an id attribute.

So I modified the QuickStart.java from org.eclipse.emf.teneo.hibernate.examples.

I only changed the following:

//		final HbDataStore hbds = HbHelper.INSTANCE
//				.createRegisterDataStore(hbName);

HbEntityDataStore hbds = new HbEntityDataStore();
hbds.setName(hbName);

I also had to add javax.persistence to the dependencies.

Can you reproduce this? I'm using my own hibernate bundle.

Need anything else?
Comment 2 Martin Taal CLA 2010-11-23 05:41:04 EST
It seems that there is a bug in the Hibernate entity meta model creation. This meta model is only needed for entity manager criteria queries and not even then. Hibernate offers a property to disable this meta model creation effectively working around this issue. I have now set this as the default behavior for the entity data store.

To try it out yourselve you need to set the following property:
hibernate.ejb.metamodel.generation
to the value:
disabled

The default setting of this property will be in the next build.
Comment 3 Martin Taal CLA 2010-11-23 06:30:33 EST
Committed to cvs and new build published
Comment 4 Flavio Donze CLA 2010-11-23 08:51:40 EST
Hi Martin

Just tested with the new build. Works! Thanks a lot for the fix