Details
-
Bug
-
Resolution: Unresolved
-
Minor
-
1.4.2.Final, 2.0.0.Alpha13
-
None
Description
The "rest endpoint-from-entity" command uses this class (ResourceGeneratorUtil).
Everything works fine if the @Id annotation is attached to a field.
However, if the @Id annotation is attached to the setXYZ() or getXYZ() method, ResourceGeneratorUtil ends up producing an incorrect name for the id property: the name should be "xyz" but this class incorrectly produces "txyz".
The problem is that the code in ResourceGeneratorUtil invokes substring(2) when it should actually have used substring(3). One site in the class correctly uses substring(3) but there are four other sites that use substring(2).
The workaround is to attach @Id to the field, not to the setter or getter methods.
Probably this bug has lain low because (a) the "entity" command always attaches @Id to the field, and (b) the JBoss Tools "New JPA Entity" wizard has an "Access Type" radio button that defaults to using the field, so the bug is only triggered if you explicitly change the radio button (or use an editor to attach the @Id annotation).