History | Log In     View a printable version of the current page. Get help!  
Issue Details [XML]

Key: EJB-53
Type: Bug Bug
Status: Reopened Reopened
Priority: Critical Critical
Assignee: Vance Karimi
Reporter: Karl-Heinz Walk
Votes: (View)
Watchers: (View)
Operations

If you were logged in you would be able to see more operations.
EJB Cartridge

Wrong class reference of associations of a MappedSuperclass

Created: 15/Apr/07 10:44 AM   Updated: 30/Nov/07 01:16 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None


 Description   
A modelled entity "XXX" with stereotype <<MappedSuperclass>> which has an association to an entity "YYY" is named "XXXEmbeddable". But in the class "YYY" the association definition is of class "XXX" instead of "XXXEmbeddable". The generated code can't be compiled.

To solve this bug I suggest that explicitly modelled mapped superclasses are NOT renamed to "XXXEmbeddable" but simply named "XXX".

 All   Comments   Change History      Sort Order:
Comment by Vance Karimi [02/May/07 05:40 PM]
I have a patch for this, but I wanted to get people's thoughts first.

Firstly, how do others feed about this. Is there anyone who would see a problem with changing this default behaviour of the cartridge?

Now, if you want to model an association to a mapped superclass, you will be faced with the following problem: http://forum.hibernate.org/viewtopic.php?t=959542

Then read the bit about the @CollectionOfElements annotations http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/#CollectionOfElements

It it scary to think this functionality can only be achieved by enabling Hibernate though, which will have to be the case just to get it working! Any thoughts?

Comment by Vance Karimi [07/May/07 03:34 PM]
This is now fixed.
You must set the persistenceProviderExtensions property to hibernate if you have OneToMany or ManyToMany references to unmapped entities (mapped superclass).

Comment by Karl-Heinz Walk [17/May/07 02:03 PM]
I used this modification and encoutered several problems/ errors:

1. With stereotype <<MappedSuperclass>> the class is generated without the member "id" and methods getId and setId. But this methods are called in the derived classes.

2. When I model the "id" member explictly in the <<MappedSuperclass>> the model will not be validated. For each derived class I get the following message:

2007-05-17 13:59:55,013 ERROR [AndroMDA] 1) [Data::aiinfosys::de.amnesty.bezirk.aiinfosys::domain::EinzelMitglied]:An undocumented constraint has been violated: context EJB3EntityFacade\r\ninv: identifiersPresent

This also happens if I annote the "id" member with @andromda.persistence.coulmn

3. I would like to have the <<MappedSuperclass>> to be abstract. If I set the flag in MagicDraw for the class I get the following error:

------- AndroMDA Exception Recording -------
Version ........: 3.3-SNAPSHOT
Error ..........: Error performing ModelProcessor.process with model(s) --> 'C:\Projects\aiinfosys\mda\src\main\uml\aiinfosys.uml2'
Build ..........: ${build.date}
Build System ...: Linux-2.4.29-su-1.2
Build JDK ......: Sun Microsystems Inc.-1.5.0_07-b03
Build Builder ..: su-builder
Run System .....: Windows XP5.1
Run JDK ........: Sun Microsystems Inc.1.5.0_06-b05
Main Exception .: org.andromda.core.cartridge.CartridgeException: Error processing template 'templates/ejb3/EntityEmbeddable.vsl' with template context '{entity=org.andromda.cartridges.ejb3.metafacades.EJB3EntityFacadeLogicImpl[Adresse], stringUtils=org.apache.commons.lang.StringUtils@15ece16, collectionUtils=org.apache.commons.collections.CollectionUtils@12c384b, transform=org.andromda.cartridges.ejb3.EJB3ScriptHelper@23cfcf, converter=org.andromda.utils.JavaTypeConverter@1204c3e, driver=com.mysql.jdbc.Driver, username=amnesty, password=andisherpa, connectionUrl=jdbc:mysql://localhost:3306/aiinfosys, dataSource=java:/jdbc/aiinfosys, dataSourceName=jdbc/aiinfosys, entityManagerName=aiinfosys, hibernateHbm2DDLAuto=update, hibernateDialect=org.hibernate.dialect.MySQLInnoDBDialect, hibernateShowSql=null, hibernateMaxFetchDepth=null, hibernateJdbcFetchSize=null, hibernateJdbcBatchSize=null, hibernateJdbcUseScrollableResultSet=null, hibernateJdbcUseStreamsForBinary=null, hibernateCacheProvider=org.jboss.ejb3.entity.TreeCacheProviderHook, hibernateTreecacheMbeanObject=jboss.cache:service=EJB3EntityTreeCache, hibernateEnableCache=false, hibernateEnableAssociationsCache=false, hibernateUseQueryCache=false, useDefaultCacheRegion=false, hibernateTransactionManagerLookupClass=null, hibernateTransactionFlushBeforeCompletion=null, hibernateTransactionAutoCloseSession=null, serviceLocatorName=ServiceLocator, manageableServiceLocatorName=ManageableServiceLocator, ejb3TypesPackage=de.amnesty.bezirk.infosys, persistenceProviderExtensions=none, persistenceContextUnitName=aiinfosys, persistenceContainerName=jboss, parameterRequiredCheck=true, xmlEncoding=UTF-8, enableTemplating=true, jndiNamePrefix=aiinfosys-1.0, securityRealm=null, manageableRolesAllowed=Admin, enableClustering=false, webServiceContextRoot=/aiinfosys-ws, webServiceUrlPattern=/services, dao-impls=C:\Projects\aiinfosys\mda/../core/src/main/java, daos=C:\Projects\aiinfosys\mda/../core/target/src, daoInheritanceEnabled=false, enableDaoPropertiesCreateMethod=true, seamEnabled=false, jarFiles=null}' using cartridge 'ejb3'
Root Exception .: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getAllEntityRelations' in class org.andromda.cartridges.ejb3.metafacades.EJB3EntityFacadeLogicImpl threw exception class java.lang.IllegalStateException : Relation 'adresse2adressierbar' has the abstract target 'Adressierbar'. Abstract targets are not allowed in EJB.
org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getAllEntityRelations' in class org.andromda.cartridges.ejb3.metafacades.EJB3EntityFacadeLogicImpl threw exception class java.lang.IllegalStateException : Relation 'adresse2adressierbar' has the abstract target 'Adressierbar'. Abstract targets are not allowed in EJB.
    at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier.java:193)
    at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:175)
    at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:327)
    at org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:51)
    at org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:95)
    at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230)
    at org.apache.velocity.Template.merge(Template.java:256)
    at org.andromda.templateengines.velocity.VelocityTemplateEngine.processTemplate(VelocityTemplateEngine.java:240)
    at org.andromda.core.cartridge.Cartridge.processWithTemplate(Cartridge.java:373)
    at org.andromda.core.cartridge.Cartridge.processTemplateWithMetafacades(Cartridge.java:235)
    at org.andromda.core.cartridge.Cartridge.processTemplate(Cartridge.java:111)
    at org.andromda.core.cartridge.Cartridge.processModelElements(Cartridge.java:62)
    at org.andromda.core.engine.ModelProcessor.processModels(ModelProcessor.java:249)
    at org.andromda.core.engine.ModelProcessor.process(ModelProcessor.java:146)
    at org.andromda.core.engine.ModelProcessor.process(ModelProcessor.java:82)
    at org.andromda.core.engine.Engine.run(Engine.java:82)
    at org.andromda.core.AndroMDA.run(AndroMDA.java:197)
    at org.andromda.maven.plugin.AndroMDAMojo.execute(AndroMDAMojo.java:92)
    at org.andromda.maven.plugin.AbstractAndroMDAMojo.execute(AbstractAndroMDAMojo.java:106)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:420)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:330)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:123)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:272)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

Comment by Vance Karimi [17/May/07 03:46 PM]
Need to investigate further.

Comment by Vance Karimi [27/Nov/07 03:06 PM]
After many days of debugging, I could not work out a way to avoid having to model the Entity stereotype as well as the MappedSuperclass stereotype and have a working uml2 model. I will be applying a patch to roll back this part of the original patch in the next day or two. This will mean that to model a mapped superclass, you will need to model the Entity and MappedSuperclass stereotypes on the class, as was the case originally with the cartridge.

If there are any objections, feel free to have a stab at this.

Comment by Vance Karimi [30/Nov/07 01:16 PM]
I've applied this patch. You now need to model the Entity and MappedSuperclass stereotypes again, but you should not longer have the problem with uml2 models.

Can one of the guys watching this issue pls try this fix and provide feedback.