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

Bug 342171

Summary: [API] Mapping One to Many - chooses override in Details and receive out-of-bounds error
Product: [WebTools] Dali JPA Tools Reporter: Jolene Moffitt <jolene.moffitt>
Component: JPAAssignee: Karen Butzke <karenfbutzke>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: karenfbutzke, nan.n.li, neil.hauge, raghunathan.srinivasan
Version: 3.0Flags: neil.hauge: pmc_approved? (david_williams)
raghunathan.srinivasan: pmc_approved+
neil.hauge: pmc_approved? (naci.dai)
neil.hauge: pmc_approved? (deboer)
neil.hauge: pmc_approved? (neil.hauge)
neil.hauge: pmc_approved? (kaloyan)
neil.hauge: pmc_approved? (cbridgha)
neil.hauge: review+
Target Milestone: 3.2 M7   
Hardware: PC   
OS: Windows Server 2003   
Whiteboard:
Attachments:
Description Flags
proposed patch against maintenance
none
proposed patch against HEAD none

Description Jolene Moffitt CLA 2011-04-07 10:48:31 EDT
Testing on build I-3.3.0-20110331154142

Create JPA 2.0, generic 2.0 project
Create an entity with two attributes
Map 1st atribute as the Id
Map 2nd as one-to-many
In details section for 2nd attribute click on join columns override default checkbox and receive the following error:
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.IllegalArgumentException: Index out of bounds)
	at org.eclipse.swt.SWT.error(SWT.java:4277)
	at org.eclipse.swt.SWT.error(SWT.java:4192)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:137)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4125)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3742)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	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:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: java.lang.IllegalArgumentException: Index out of bounds
	at org.eclipse.swt.SWT.error(SWT.java:4258)
	at org.eclipse.swt.SWT.error(SWT.java:4192)
	at org.eclipse.swt.SWT.error(SWT.java:4163)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:468)
	at org.eclipse.swt.widgets.Table.remove(Table.java:3232)
	at org.eclipse.jpt.common.ui.internal.swt.TableModelAdapter.listItemsRemoved(TableModelAdapter.java:417)
	at org.eclipse.jpt.common.ui.internal.swt.TableModelAdapter$2.itemsRemoved(TableModelAdapter.java:244)
	at org.eclipse.jpt.common.ui.internal.listeners.SWTListChangeListenerWrapper.itemsRemoved_(SWTListChangeListenerWrapper.java:177)
	at org.eclipse.jpt.common.ui.internal.listeners.SWTListChangeListenerWrapper$2.run(SWTListChangeListenerWrapper.java:101)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
	... 23 more
Comment 1 Pascal Filion CLA 2011-04-27 21:01:07 EDT
I fix the bug reported for M7. However, if the user clicks on "Override Default" check box many times rapidly, then the same exception and others will be thrown.
Comment 2 Pascal Filion CLA 2011-05-04 07:31:17 EDT
Recent changes fixed the remaining issue.
Comment 3 Neil Hauge CLA 2011-05-31 16:00:15 EDT
Still seeing these problems...Nan will comment further.
Comment 4 Nan Li CLA 2011-05-31 16:20:45 EDT
1. Go to "Java" entity -> Inheritance -> Primary key join columns
2. Try to select Override default checkbox

The same exception as what described in the bug description is thrown.
Comment 5 Nan Li CLA 2011-06-01 14:30:41 EDT
Java/Orm Entity:

1. In JPA Details, go to entity -> Secondary Tables
2. Add a secondary table and select it
3. Try to select Primary key join columns -> Override default checkbox

The same exception as what described in the bug description is thrown.

Orm Entity:

1. Go to Java entity -> Secondary Tables to add a secondary table
2. Add the Java entity to the mapping xml
3. Go to Orm entity -> Secondary Tables
4. Try to select "Define in XML" check box
5. Select the secondary table in the list and then try to select Primary key join columns -> Override default checkbox

The same exception as what described in the bug description is thrown at both step 4 & 5.
Comment 6 Neil Hauge CLA 2011-07-01 16:23:38 EDT
Moving JPA specific bugs to new JPA component in bugzilla.
Comment 7 Karen Butzke CLA 2011-10-19 09:42:34 EDT
*** Bug 310720 has been marked as a duplicate of this bug. ***
Comment 8 Karen Butzke CLA 2011-10-19 09:43:20 EDT
Please check the duplicate bug 310720 for more use cases.
Comment 9 Karen Butzke CLA 2011-10-19 10:03:22 EDT
Created attachment 205528 [details]
proposed patch against maintenance
Comment 10 Neil Hauge CLA 2011-10-20 11:42:03 EDT
Tested patch against maintenance.  I was unable to reproduce the original problem.  I was able to get the exception using Secondary Tables, but it was difficult to reproduce (required rapid clicking of Override checkbox for over 10 seconds).  As you mentioned this patch wasn't expected to solve issue of Secondary Tables join column override selection.
Comment 11 Karen Butzke CLA 2011-10-25 16:13:16 EDT
This patch is causing issues with adding multiple join columns to a relationship mapping and then changing the joining strategy to mappedBy or joinTable. There is going to need to be a larger fix to fix this issue.
Comment 12 Karen Butzke CLA 2012-05-02 12:04:17 EDT
The exceptions are happening because the UI is editing the model while changes are happening in the update thread. I have pushed the code in the UI down to the model where it belongs. Then the model changes can be completed in a batch fashion and not cause the update to happen while the context model is still changing.


To fix this issue I need to add the following provisional API methods:

org.eclipse.jpt.jpa.core.context.Entity
PrimaryKeyJoinColumn getSpecifiedPrimaryKeyJoinColumn(int index);
void convertDefaultPrimaryKeyJoinColumnsToSpecified();
void clearSpecifiedPrimaryKeyJoinColumns();

org.eclipse.jpt.jpa.core.context.JoinColumnRelationshipStrategy
void convertDefaultJoinColumnsToSpecified();
void clearSpecifiedJoinColumns();

org.eclipse.jpt.jpa.core.context.SecondaryTable
PrimaryKeyJoinColumn getSpecifiedPrimaryKeyJoinColumn(int index);
void convertDefaultPrimaryKeyJoinColumnsToSpecified();
void clearSpecifiedPrimaryKeyJoinColumns();

org.eclipse.jpt.jpa.core.context.ReferenceTable
void clearSpecifiedJoinColumns();
The other related provisional API already existed including JoinTable.clearSpecifiedInverseJoinColumns() etc
Comment 13 Karen Butzke CLA 2012-05-02 12:04:54 EDT
Created attachment 214936 [details]
proposed patch against HEAD
Comment 14 Karen Butzke CLA 2012-05-02 12:12:40 EDT
Neil could you review this patch? I am running unit tests right now and I have sent a note out to the dev list about the provisional API changes.
Comment 15 Neil Hauge CLA 2012-05-02 13:31:06 EDT
Patch looks good.  Testing looks good.
Comment 16 Neil Hauge CLA 2012-05-02 13:44:38 EDT
Requesting PMC approval for a provisional API addition to fix a nasty UI regression.  The fix is a bit on the large side, but isolated to the problem areas, as the new API and implementation are only used in the places where the UI functionality was broken.  This is a movement of behavior out of the UI and into the model where it should have originally been.  

See comment 12 for additional information.
Comment 17 Raghunathan Srinivasan CLA 2012-05-02 14:29:41 EDT
Agree on the change with the usual caution on the need for adequate testing.
Comment 18 Neil Hauge CLA 2012-05-02 19:29:26 EDT
Patch committed to head.
Comment 19 Karen Butzke CLA 2012-05-03 10:51:29 EDT
*** Bug 347218 has been marked as a duplicate of this bug. ***
Comment 20 Jolene Moffitt CLA 2012-05-09 12:06:06 EDT
Verified in Build I-3.4.0-20120507135259 

Verified that no errors appear when you click on the override defaults checkbox in the different areas of the application.  See the link to view test steps for verification. http://wiki.eclipse.org/Dali_3.2_M7