This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 124225 - "persistent attribute should be encapsulated" warning is wrong
Summary: "persistent attribute should be encapsulated" warning is wrong
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 6.x
Hardware: Macintosh All
: P3 blocker (vote)
Assignee: Andrei Badea
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-18 20:50 UTC by sarnoth
Modified: 2008-01-23 17:17 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sarnoth 2007-12-18 20:50:02 UTC
I am able to turn on and off a bunch of different editor hints for general Java code through Preferences->Java
Code->Hints, however I don't see a way to do the same thing with JavaEE hints. One hint in particular causes me problems
because it fills my editor with a bunch of marks making it hard for me to see when there is really something that
deserves my attention. I would like to be able to decide what hints I want to see.

The hint that causes me problems is "persistent attribute should be encapsulated". I annotate entity attributes directly
instead of the accessor methods. My attributes are private so encapsulation is not a problem. This allows me greater
control so that I can leave off the setter for attributes that I don't want to be changed by external code or even leave
off the getter for for attributes that are important to my persistence model but are not relevant to the public API.
This hint tells me that I am wrong every time I do this and there are so many of them that it is impossible to find the
useful hints that might really indicate a problem.
Comment 1 Tomasz Slota 2007-12-28 14:14:31 UTC
The ability to suppress JavaEE verification warnings is already being tracked as issue 87922.

The "persistent attribute should be encapsulated" warning is probably wrong (to be verified). The relevant spec chapter is 2.1.1 (Persistent Fields and 
Properties).
Comment 2 Andrei Badea 2008-01-16 17:18:40 UTC
It seems to me the warning should be removed. If the Java support doesn't display a hint that a field should be
encapsulated, why should the JPA support? There is nothing in the JPA spec (section 2.2.1) requiring field encapsulation
when field-based access is used.
Comment 3 Andrei Badea 2008-01-16 17:19:33 UTC
Tomasz, any opinion to desc3?
Comment 4 Andrei Badea 2008-01-21 13:34:56 UTC
Fixed by removing the hint. I will add a comment to issue 87922 to re-add the hint when that issue is addressed.

Removing src/org/netbeans/modules/j2ee/jpa/verification/rules/attribute/AttrIsEncapsulated.java;
/cvs/j2ee/persistence/verification/src/org/netbeans/modules/j2ee/jpa/verification/rules/attribute/AttrIsEncapsulated.java,v
 <--  AttrIsEncapsulated.java
new revision: delete; previous revision: 1.5
done
Checking in src/org/netbeans/modules/j2ee/jpa/verification/rules/attribute/Bundle.properties;
/cvs/j2ee/persistence/verification/src/org/netbeans/modules/j2ee/jpa/verification/rules/attribute/Bundle.properties,v 
<--  Bundle.properties
new revision: 1.12; previous revision: 1.11
done
Checking in src/org/netbeans/modules/j2ee/jpa/verification/rules/entity/ValidAttributes.java;
/cvs/j2ee/persistence/verification/src/org/netbeans/modules/j2ee/jpa/verification/rules/entity/ValidAttributes.java,v 
<--  ValidAttributes.java
new revision: 1.16; previous revision: 1.15
done
Comment 5 Andrei Badea 2008-01-23 17:17:13 UTC
Also:

Checking in src/org/netbeans/modules/j2ee/jpa/verification/fixes/Bundle.properties;
/cvs/j2ee/persistence/verification/src/org/netbeans/modules/j2ee/jpa/verification/fixes/Bundle.properties,v  <-- 
Bundle.properties
new revision: 1.17; previous revision: 1.16
done
Removing src/org/netbeans/modules/j2ee/jpa/verification/fixes/EncapsulateFieldHint.java;
/cvs/j2ee/persistence/verification/src/org/netbeans/modules/j2ee/jpa/verification/fixes/EncapsulateFieldHint.java,v  <--
 EncapsulateFieldHint.java
new revision: delete; previous revision: 1.3
done