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

Bug 325531

Summary: Adding new attribute adds Basic annotation without import
Product: [WebTools] Dali JPA Tools Reporter: Karen Butzke <karenfbutzke>
Component: Diagram EditorAssignee: Petya Sabeva <petya.sabeva>
Status: RESOLVED FIXED QA Contact: Stefan Dimov <stefan.dimov>
Severity: normal    
Priority: P3 CC: petya.sabeva
Version: 0.5   
Target Milestone: 0.5 RC3   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 338725    
Attachments:
Description Flags
adding import statement if not exists stefan.dimov: iplog+

Description Karen Butzke CLA 2010-09-16 17:42:46 EDT
I am testing with 0.5RC2.
In the JPA diagram editor I added a new attribute to an entity. The attribute was added along with the @Basic annotation, but no import was added so the class no longer compiles. I think adding the @Basic annotation is unnecessary since that will be the default mapping type.
Comment 1 Petya Sabeva CLA 2010-10-04 06:54:14 EDT
Hi Karen,

I cannot reproduce it. Actually when a new entity is created in the JPA Diagram Editor, the whole package org.persistence.* is imported. So the reason, that the class is not compiled after attribute is added, is not the import statement. Sometimes there is a problem with the compilation unit's validation itself. The compilation unit is fine, but while it is not saved, it is marked as non compilable and when you save the source code, everything is fine. So there isn't problem to remove the "@Basic" annotation, but it will not resolve the issue.
Comment 2 Stefan Dimov CLA 2010-10-04 09:23:31 EDT
I agree with Petya ...
Comment 3 Karen Butzke CLA 2010-10-04 14:29:47 EDT
Ok, I have narrowed down the use case. If you create the Entity not using the diagram and just import javax.persistence.Entity then add the entity to the diagram and add an attribute. In this case the import is not added. I can't make it happen if I create the entity in the diagram. I think this should be a valid use case so I have reopened the bug.
Comment 4 Karen Butzke CLA 2010-10-04 14:37:48 EDT
One option to fix this would be to not add the @Basic annotation at all. Since this is the default attribute mapping type in JPA it would be valid to not put an annotation when adding a new attribute.
Comment 5 Stefan Dimov CLA 2010-10-05 04:46:58 EDT
I agree with Karen. The import should be added or the @Basic annotation should not be added at all.
Comment 6 Petya Sabeva CLA 2010-10-05 10:31:10 EDT
Created attachment 180246 [details]
adding import statement if not exists
Comment 7 Stefan Dimov CLA 2010-10-07 11:25:17 EDT
The patch is committed