]
Lincoln Baxter III updated FORGE-1267:
--------------------------------------
Fix Version/s: 2.x Future
rest/ResourceGeneratorUtil generates bogus id name from Method
--------------------------------------------------------------
Key: FORGE-1267
URL:
https://issues.jboss.org/browse/FORGE-1267
Project: Forge
Issue Type: Bug
Components: Java EE APIs
Affects Versions: 1.4.2.Final, 2.0.0.Alpha13
Reporter: Thomas Maslen
Priority: Minor
Fix For: 2.x Future
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).
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: