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.
[ JDK VERSION : 1.8.0_45 ] 1. create a jpa 2.1 (with EclipseLink) entity model that uses single-table inheritance, with a base class, and two other classes that extend the base class. eg: a, a1, a2, using the default dtype string column mechanism for single-table inheritance. 2. create two additional tables to which a join hierarchy is formed between them. eg: a <- b <- c 3. create a query that provides the id for c, which uses joins to be able to obtain the related 'a' records, with a query similar to this: SELECT a FROM A a JOIN a.b b JOIN b.pId c WHERE c.thingId = '01234567890'; the result in the output will only contain the discriminator column, in my example.
btw: 'a' entity should have multiple data columns, which 'a1' and 'a2' also inherit.
Reassigning to javaee, the described component (JPQLEditorTopComponent) is located in the j2ee.persistence module.
Created attachment 157152 [details] sample project
Sample data/schema for project: CREATE TABLE A (ID INTEGER GENERATED ALWAYS AS IDENTITY, DTYPE VARCHAR(31), TITLE VARCHAR(255), TITLEID INTEGER, PRIMARY KEY (ID)); INSERT INTO A (DTYPE, TITLE, TITLEID) VALUES ('A1', 'X', NULL); INSERT INTO A (DTYPE, TITLE, TITLEID) VALUES ('A2', NULL, 1); INSERT INTO A (DTYPE, TITLE, TITLEID) VALUES ('A2', NULL, 2); INSERT INTO A (DTYPE, TITLE, TITLEID) VALUES ('A2', NULL, 3); INSERT INTO A (DTYPE, TITLE, TITLEID) VALUES ('A1', NULL, NULL); ---------- Sample jpa query: select a from a1 a
Created attachment 157153 [details] proposed patch The problem lies in the reflection usage. The code scans the object, extracts the class of the object and then iterates over its declares methods. This misses the inherited methods and explains the problem pbeldin sees. The logic only works without inheritance and with homogeneous results. The attached patch changes the logic and does this: Directly after getting the result the whole resultset is scanned. First step is determining if an object list is created or a object[] list is created. The be handled as object[] all returned rows have to be arrays and be of same length and none may be none. If one of the constraint is violated the list is asumed to be a list of objects. From the list "ReflectionInfo" is gathered - this consists of a column index and a property name. Column index is only non-null if each row is an array and denotes the index. Property name is null if the value is a basic type and the propertyname if attributes of the object are displayed. Based on the ReflectionInfo the ReflectiveTableModel i constructed, that fetches the correct value from the backing data on the fly.
Slightly modified patch pushed as web-main b49685f71ac5. Thanks for it!
Integrated into 'main-silver', will be available in build *201605200002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/b49685f71ac5 User: Petr Hejl <phejl@netbeans.org> Log: #256032 - JPQL result pane does not show all columns