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

Bug 347993

Summary: ClassCastException: GenericOrmVirtualSecondaryTable cannot be cast to SecondaryTable
Product: [WebTools] Dali JPA Tools Reporter: Nan Li <nan.n.li>
Component: JPAAssignee: Nan Li <nan.n.li>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jolene.moffitt, neil.hauge
Version: unspecified   
Target Milestone: 3.3   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Stack Trace none

Description Nan Li CLA 2011-06-01 14:52:17 EDT
Build Identifier: I20110525-0800

1. Go to a Java entity -> Secondary Tables to add a secondary table
2. Add the Java entity to a mapping xml
3. Go to Orm entity -> Secondary Tables and select "Define in XML" checkbox
4. Select the secondary table in the list and then click Remove button to remove the secondary table from the mapping xml

An CCE exception is thrown saying 

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.ClassCastException: org.eclipse.jpt.jpa.core.internal.context.orm.GenericOrmVirtualSecondaryTable cannot be cast to org.eclipse.jpt.jpa.core.context.SecondaryTable)

The full stack trace is attached.

Reproducible: Always
Comment 1 Nan Li CLA 2011-06-01 14:53:08 EDT
Created attachment 197145 [details]
Stack Trace
Comment 2 Neil Hauge CLA 2011-06-02 12:45:10 EDT
Interesting...I'm not able to reproduce this one in the RC3 candidate.  It would seem that in your case, after defining the table in XML, the secondary table is remaining virtual for some reason.  You shouldn't be able to remove a virtual secondary table from that list, since once you have enabled the list (by defining the secondary table in XML), the contents should no longer be virtual.  I suppose this is likely another race condition.
Comment 3 Nan Li CLA 2011-06-02 12:51:43 EDT
After selecting the "Define in XML" checkbox, the one defined on Java entity will be written to the mapping xml. At this point, trying to remove the one listed should be able to reproduce this problem.
Comment 4 Nan Li CLA 2011-06-02 12:58:43 EDT
This happens after removing all the listed secondary tables.
Comment 5 Neil Hauge CLA 2011-06-02 13:02:30 EDT
(In reply to comment #3)
> After selecting the "Define in XML" checkbox, the one defined on Java entity
> will be written to the mapping xml. At this point, trying to remove the one
> listed should be able to reproduce this problem.

Yes, I am sure it does in your case, but it doesn't happen for me. :)  I was just saying that the secondary table shouldn't be virtual at the point of removing it from the list, but in your case it obviously is. : )
Comment 6 Neil Hauge CLA 2011-07-01 16:26:25 EDT
Moving JPA specific bugs to new JPA component in bugzilla.
Comment 7 Neil Hauge CLA 2011-10-07 12:51:59 EDT
Targeting to Juno release.
Comment 8 Nan Li CLA 2012-05-25 17:04:19 EDT
Note -> I can still reproduce this problem in 3.2 RC2 candidate.
Comment 9 Nan Li CLA 2012-07-13 11:58:48 EDT
I am not able to reproduce this problem with Juno release. Neil, should I close this bug or need to go back to maintenance to check?
Comment 10 Nan Li CLA 2012-07-13 12:10:00 EDT
Sorry, I forgot to open the Error Log. I still get the exception with Juno release.
Comment 11 Nan Li CLA 2012-07-13 14:38:30 EDT
I can not reproduce the problem with the latest head code thinking maybe Karen's recent big changes to the UI code have already fixed the problem so I close it for now.
Comment 12 Jolene Moffitt CLA 2012-10-16 11:33:35 EDT
Verified in build I-3.5.0-20121003040013 that you can remove secondary tables from the entity in the mapping file without error.  To view steps to verify this issue go to http://wiki.eclipse.org/Dali_3.3_Release