• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

CMR

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Me again.
I'm slightly confused over CMRs (this might really be a question for Mr Brown). When you have a CMR with a bean that has a composite (compound) key, what value should go in the CMR field? Should it store the whole key object? I've only managed to find examples of CMR where the key is a single field. I've been having battles with WSAD over CMRs for the past couple of days now...
Can anyone point me in the direction of some good examples please, or offer some advice?
tia,
Tim
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It shouldn't be that difficult. First of all, are you doing a top-down or meet-in-the-middle mapping? If it's top-down, it's a no brainer -- just make sure your target EJB has a composite primary key and create a CMR as usual -- WebSphere will work everything out.
Meet-in-the-middle isn't much harder. First, make sure you begin by creating a foreign key in the table mapper for the source table that contains BOTH parts of the primary key of the target table. Obviously your source table will have to have two columns in it, one for each part of the foreign key. Then in the Map.xmi editor, you simply map that foreign key to the CMR relationship that you set up.
Kyle
 
Tim Cunnell
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah ok, I think I'm getting somewhere now.
Still a bit confused though, because my composite key is made up of three parts. The relationship is like this...
We have a Warehouse table that has 1-many Store tables which has 1-many Location tables.
Location has a primary key made up of locationRef, storeRef and warehouseRef.
Store's primary key is made up of storeRef and WarehouseRef.
Warehouse's primary key is just warehouseRef.
Location has a CMR with Store and store has a CMR with Warehouse.
It seems to me that Location needs a CMR with Warehouse.. is this true? I thought Location would only need a CMR with Store.
Sorry if I'm being a dullard here!
cheers
Tim
 
Tim Cunnell
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty sure I've got it set up correctly (as you suggested) but I'm getting errors that getStore_storeRef() and getWarehouse_warehouseRef() are not implemented in LocationBeanCacheEntry... when I generate my deploy code. Websphere _has_ generated those abstract method signatures on the bean, but seems it can't/won't generate the implementations when it's generating deploy code.
I also get problems when I try to put in the CMR between the Warehouse and Store beans - deploy code generation falls over with this error :
Error during generation of deployment code: cols.size()==2, attrs.size()==0
>com.ibm.etools.ejbdeploy.EJBDeploymentException (Error during generation of deployment code: cols.size()==2, attrs.size()==0.)
com.ibm.etools.ejbdeploy.plugin.InternalErrorGenerationException: cols.size()==2, attrs.size()==0
at com.ibm.etools.ejbdeploy.gen20.jdbc.CMPAttributeMapHelper.createMapForRel(CMPAttributeMapHelper.java:253)
at com.ibm.etools.ejbdeploy.gen20.jdbc.CMPAttributeMapHelper.populateLists(CMPAttributeMapHelper.java(Compiled Code))
at com.ibm.etools.ejbdeploy.gen20.jdbc.CMPAttributeMapHelper.initAttributeMapperList(CMPAttributeMapHelper.java:378)
at com.ibm.etools.ejbdeploy.gen20.jdbc.QueryCacheHelper.<init>(QueryCacheHelper.java:30)
at com.ibm.etools.ejbdeploy.gen20.jdbc.QueryCacheCache.initQueries(QueryCacheCache.java:69)
at com.ibm.etools.ejbdeploy.gen20.jdbc.QueryCacheCache.init(QueryCacheCache.java:154)
at com.ibm.etools.ejbdeploy.plugin.EJBDeployOperation.runCMP(EJBDeployOperation.java:1501)
at com.ibm.etools.ejbdeploy.plugin.EJBDeployOperation.run(EJBDeployOperation.java:1364)
at com.ibm.etools.j2ee.common.ui.RunnableWithProgressWrapper.run(RunnableWithProgressWrapper.java:58)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:299)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:249)
at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:720)
at com.ibm.etools.ejbdeploy.ui.plugin.DeployRMICBeansOperation.generateDeployCode(DeployRMICBeansOperation.java:245)
at com.ibm.etools.ejbdeploy.ui.plugin.DeployRMICBeansOperation.run(DeployRMICBeansOperation.java:555)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java(Compiled Code))
at com.ibm.etools.ejbdeploy.ui.plugin.DeployRMICPage.performFinish(DeployRMICPage.java:446)
at com.ibm.etools.ejbdeploy.ui.plugin.DeployRMICWizard.performFinish(DeployRMICWizard.java:83)
at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:577)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:312)
at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:407)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java(Compiled Code))
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java(Compiled Code))
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java(Compiled Code))
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java(Compiled Code))
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java(Compiled Code))
at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code))
at org.eclipse.jface.window.Window.open(Window.java:542)
at com.ibm.etools.ejbdeploy.ui.plugin.EJBDeployMenuAction.run(EJBDeployMenuAction.java:165)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:210)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:407)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java(Compiled Code))
at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java(Compiled Code))
at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java(Compiled Code))
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java(Compiled Code))
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java(Compiled Code))
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java(Compiled Code))
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java(Compiled Code))
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java(Compiled Code))
at org.eclipse.ui.internal.Workbench.run(Workbench.java:1326)
at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:831)
at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462)
at java.lang.reflect.Method.invoke(Native Method)
at org.eclipse.core.launcher.Main.basicRun(Main.java:247)
at org.eclipse.core.launcher.Main.run(Main.java:703)
at org.eclipse.core.launcher.Main.main(Main.java:539)
Ugh, nasty! I noticed that when I put in the CMR between my Warehouse and Store, stuff gets added to the LocationBean to pass in the foreign key for Warehouse. So I created a CMR between Location and Warehouse (even though I don't really want one), mapped it etc etc and still got the above error.
Eek, help!
cheers
Tim
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not being dull, Tim. This "part-whole" problem (called "Weak Entities" in relational modeling) is one of the more challenging ones in object-relational mapping. I BELIEVE you're right that you'll need a CMR to the Warehouse. Then you'll need to use the "Add to Key" button in the Relationships Area of the overview page to add both relationships to the primary key of location.
I've been working (on and off) on an article about this for a while. I'll let you know when I'm ready to have something reviewed.
Kyle
 
Tim Cunnell
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I'd like to read that article, please let me know when it's done.
I've added the Location-Warehouse CMR, but I still can't find the problem with the deploy code/query generation. Can you tell me why the exception in the message above might be getting thrown?
 
Tim Cunnell
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll have a look, thanks.
Tim
 
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic