Community
Participate
Working Groups
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.
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.
I agree with Petya ...
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.
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.
I agree with Karen. The import should be added or the @Basic annotation should not be added at all.
Created attachment 180246 [details] adding import statement if not exists
The patch is committed