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.
Uncompilable source code can be generated by the"RESTful Web Services from Entity Classes..." wizard if it is run on two related entity classes when these classes have no getter and setter methods for the fields that relate them. The uncompilable classes are converter and service classes. -------------------------------------------------------- Entity1.java: -------------------------------------------------------- ... @Entity public class Entity1 implements Serializable { @OneToMany(mappedBy = "entity1") private List<Entity2> entity2s; private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; public Long getId() { return id; } public void setId(Long id) { this.id = id; } } -------------------------------------------------------- Entity2.java: -------------------------------------------------------- ... @Entity public class Entity2 implements Serializable { @ManyToOne private List<Entity2> entity1; private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; public Long getId() { return id; } public void setId(Long id) { this.id = id; } } The "RESTful Web Services from Entity Classes..." seems to generate the converter classes with the assumption that these getter methods exist. For example, it will generate the following method in Entity2Converter.java: @XmlElement public Entity1Converter getEntity1() { if (expandLevel > 0) { if (entity.getEntity1() != null) { return new Entity1Converter(entity.getEntity1(), uri.resolve("entity1/"), expandLevel - 1, false); } } return null; } Note that the getEntity1() method does not exist and the code is uncompilable. I suppose what I might expect here is for the wizard to create the required getter and setter methods in these entity classes (with confirmation). It may also be sufficient to provide a message in the wizard indicating that the code generated will not compile when this occurs.
Created attachment 105135 [details] Web App Project with RESTful Web Services generated from entity classes resulting in uncompilable services
Right the issue exists. The scenario is uncommon because of bean attribute without accessor methods. I would object from entity beans modifications. The entity beans are the original data and it is not good to modify the data. I would suggest to change algorithm of source code generation.
This issue will not be fixed. The reasons are: 1) For the nearest release this is not a big issue : absence of accessors for entity attribute break the java beans contract. So the scenario is rare and not valid from very beginning. 2) There is an issue #189723 which is already fixed but I can't include the source code into the trunk for 7.0 release. There are a lot of code changes and it is too risky. There will be no any converters but RESTful WS will handle corresponding entity only ( without its references ) after commit for mentioned issue . Any persistence aspects will be handled by persistence functionality ( JPA controller ). So the original issue will just disappear . The source code for RESTful WS will looks mostly the same as generated code for WS with JEE6 profile. You can use this profile for your application because you use GF which supports JEE6 profile.