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.
Right now the Entity from DB wizard generates named queries for most fields. In the case of a composite pk, it generates: findBy<Field1> findBy<Field2> ... findBy<FieldN> We really need to generate a named query like this (example case of order/lineitem): name: findByPrimaryKey query: SELECT o FROM Orderitem o WHERE o.orderitemPK.orderid = :orderid and o.orderitemPK.lineitemid = :lineitemid The questions for HIE (Jano) are: 1) What should this new query be named? Choices are: - findBy<Field1><Field2>...<FieldN> - findById - findByP(rimary)K(ey) - findByCompositeP(rimary)K(ey) - something else? Note that the generated PK class uses "PK" but the annotations for pk field use "Id". 2) If we choose a name other than the first one (involving field names), should we rename the named query for the non-composite case? For example, today we have Employee with a pk of empid, so we generate findByEmpid. Should that be renamed to findById or whatever we decide in 1? Pros: consistency Cons: might confuse users since we are releasing 5.5 with the field name (findByEmpid) way 3) Should this new joined findByPK named query replace the individual findBy<Field1>, findBy<Field2>,...,findBy<FieldN> queries? Or should it augment them? Most of them are not too useful on their own, but there is the case of overlapping pk/fk case that makes one of them useful. If we choose to keep the overlapping pk/fk case - it is more like a relationship field query and we don't generate those now. We might have a bigger task to look at those. Also, we need to consider 5.5 users who have all of these generated if we no longer generate them....
These are not questions for HIE. These are questions for people working on JPA support. Rochelle and Marina, I'd appreciate your input. Ad #1: it seems we should use either findBy<Field1><Field2>...<FieldN> or findById. The former makes sense because it is consistent with the single-field queries, the latter is consistent with many people naming primary key columns "ID". Of course, this is not consistent with naming composite primary key classes <Entity>PK, if we want to keep that we should rather use findByP(k|K). Note that if, in the future, we also decide to generate queries for composite indexes (named findBy<Field1>...<FieldN>), there would be not way to tell the queries for the primary key and indexes apart. The findBy(Id|PK) name would make more sense in this light. Ad #2,3: it could not only confuse users, but also break their existing code. It would be better IMO to generate queries that make sense, that is, for the primary key and indexed columns. But there could probably be an option to generate queries for all columns (turned off by default). Not sure about queries for relationships -- aren't those covered by the relationships between entity classes? This issue looks more like an enhancement to me.
Andrei, you have our input, as I am the one who filed the initial bug and ran the text by Marina before doing so. We wanted HIE's input mainly on the consistency/compatibility issues. I think the initial bug description does a decent job of discussing the pros/cons.
There are many questions in the initial descriptions. I was asking if you have any answers to those questions, e.g. if you prefer any of the possible primary key query name, etc.
No real preferences, mostly asking for input.
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue. Thanks for your cooperation, NetBeans IDE 8.2 Release Boss