By default Roo excludes the entity @Id fields from the create.jspx and update.jspx views. While expected for the automatically generated identifiers this behavior seems incomplete for the ‘manually’ managed ids (e.g. without @GeneratedValue annotation).
The following example illustrates the issue:
1. New entity with string identifier (myId) and single string attribute (firstName)
2. From STS move the myId attribute (with the annotations) from the Person_Roo_Entity.aj to the Person.java, add getter/setter for it and remove the @GeneratedValue(..) annotation.Code:entity --class ~.domain.Person --identifierField myId --identifierType java.lang.String field string --fieldName firstName
Roo detects the change and removes the myId from the Person_Roo_Entity.aj
The myId attribute inside the Person class looks like:
3. Create a scaffold controller for the Person:Code:@Id @Column(name = "myId") private String myId;
The result crete/update jspx views include only the 'firstName' attribute and if you try to save the object an exception is thrown due to uninitialized myId field.Code:controller scaffold --entity ~.domain.Person --class ~.web.PersonController
Is there a way to make the controller command aware of the 'manual' semantics of the identifier?
My Dev Environment:
--------------------------------------------
Roo :1.0.1.RELEASE [rev 601]
STS : 2.3.0.RELEASE [Build Id: 200912171331]
Java :build 1.6.0_16-b01


Reply With Quote
