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

Bug 363777

Summary: Issue when Mapping a map structure with bag or ibag = true
Product: [Modeling] EMF Reporter: Herve Ferreira <hferreira25>
Component: TeneoAssignee: Martin Taal <mtaal>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
EMF Test Project
none
Full Stack Trace Error log none

Description Herve Ferreira CLA 2011-11-15 03:24:31 EST
Build Identifier: Eclipse M20110909-1335; Teneo Version: 1.2.0.v201109010820

When setting bag or ibag = true and when having an Map in your EMF model an exception is thrown when trying to create you hbm file.

Reproducible: Always

Steps to Reproduce:
1. Create an EMF model with List and Maps
2. Try to create the HBM file programmatically 

Use the following properties

> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
> props.setProperty(Environment.USER, "root");
> props.setProperty(Environment.PASS, "mysql");
> props.setProperty(Environment.URL, "jdbc:mysql://localhost:3306/tnt5");
> props.setProperty(Environment.DIALECT, org.hibernate.dialect.MySQLDialect.class.getName());
>
> props.setProperty("hibernate.hbm2ddl.auto", "update");
> props.setProperty("teneo.mapping.force_lazy", "true");
> // props.setProperty("teneo.mapping.fetch_one_to_many_extra_lazy", "false");
> // props.setProperty("teneo.mapping.set_proxy", "true");
>
>
> props.setProperty("teneo.mapping.inheritance", "JOINED");
> props.setProperty("teneo.mapping.always_version", "false");
> props.setProperty("teneo.mapping.optimistic_locking", "false");
> // props.setProperty("teneo.mapping.always_map_list_as_bag", "true");
> props.setProperty("teneo.mapping.map_all_lists_as_idbag", "true");
> // props.setProperty("teneo.mapping.join_table_for_non_contained_associations", "true");
> // props.setProperty("teneo.mapping.set_entity_automatically", "true");
> // props.setProperty(PersistenceOptions.EMAP_AS_TRUE_MAP, "true");
>
>
> String dataStoreName = "LibraryDataStore";
>
> HbDataStore dataStore = HbHelper.INSTANCE.createRegisterDataStore(dataStoreName);
> dataStore.setDataStoreProperties(props);
>
> //HbSessionDataStore dataStore = (HbSessionDataStore) HbHelper.INSTANCE.createRegisterDataStore(dataStoreName);
> //Configuration cfg = new Configuration().configure("persistence.xml");
> //dataStore.setConfiguration(cfg);
>
>
>
> dataStore.setEPackages(new EPackage[] { OjeandbPackage.eINSTANCE, PessoaPackage.eINSTANCE });
>
> // initialize the data store, which creates the tables
> try {
> dataStore.initialize();
> } finally {
> // print the generated mapping
> System.err.println(dataStore.getMappingXML());
> }
>
>
>
>
>
>
>
>
> null
> java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EReferenceImpl cannot be cast to org.eclipse.emf.ecore.EAttribute
> at org.eclipse.emf.teneo.hibernate.mapper.OneToManyMapper.processOtMUni(OneToManyMapper.java:189)
> at org.eclipse.emf.teneo.hibernate.mapper.OneToManyMapper.process(OneToManyMapper.java:57)
> at org.eclipse.emf.teneo.hibernate.mapper.FeatureMapper.processPAnnotatedEReference(FeatureMapper.java:191)
> at org.eclipse.emf.teneo.hibernate.mapper.FeatureMapper.process(FeatureMapper.java:107)
> at org.eclipse.emf.teneo.hibernate.mapper.EntityMapper.processFeature(EntityMapper.java:725)
> at org.eclipse.emf.teneo.hibernate.mapper.EntityMapper.processFeatures(EntityMapper.java:612)
> at org.eclipse.emf.teneo.hibernate.mapper.EntityMapper.processEntity(EntityMapper.java:426)
> at org.eclipse.emf.teneo.hibernate.mapper.HibernateMappingGenerator.processPAClass(HibernateMappingGenerator.java:238)
> at
> org.eclipse.emf.teneo.hibernate.mapper.HibernateMappingGenerator.processPersistentClasses(HibernateMappingGenerator.java:180)
>
> at org.eclipse.emf.teneo.hibernate.mapper.HibernateMappingGenerator.generate(HibernateMappingGenerator.java:124)
> at org.eclipse.emf.teneo.hibernate.mapper.HibernateMappingGenerator.generateToString(HibernateMappingGenerator.java:149)
> at org.eclipse.emf.teneo.hibernate.HbDataStore.mapEPackages(HbDataStore.java:1030)
> at org.eclipse.emf.teneo.hibernate.HbSessionDataStore.mapModel(HbSessionDataStore.java:192)Commit Done *ERRORS*
>
> at org.eclipse.emf.teneo.hibernate.HbSessionDataStore.initialize(HbSessionDataStore.java:98)
> at com.nsn.CreateHBM.main(CreateHBM.java:66)
> Exception in thread "main" java.lang.NullPointerException
> at com.nsn.CreateHBM.main(CreateHBM.java:90)
Comment 1 Martin Taal CLA 2011-11-15 06:12:50 EST
I published a new build which hopefully solves this exception, can you check if it now works as expected (with idbag/bag)?

gr. Martin
Comment 2 Herve Ferreira CLA 2011-11-15 08:52:36 EST
Created attachment 207024 [details]
EMF Test Project
Comment 3 Herve Ferreira CLA 2011-11-15 08:53:47 EST
Created attachment 207025 [details]
Full Stack Trace Error log
Comment 4 Herve Ferreira CLA 2011-11-15 08:54:50 EST
Know it's a different bug

You can see that I've added two files,

The project that we use to test
The full stack trace error log
Comment 5 Herve Ferreira CLA 2011-11-15 09:50:28 EST
Know it's a different bug

You can see that I've added two files,

The project that we use to test
The full stack trace error log
Comment 6 Martin Taal CLA 2011-11-15 23:53:52 EST
Thanks for providing a test model, I used that for a testcase.

A solution is published in the latest build. Can you check it, if it still occurs please re-open this issue.

gr. Martin
Comment 7 Martin Taal CLA 2011-11-15 23:54:03 EST
Published