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.

Bug 190515 - Can't create dependent entity, case id class-id class, @unable to find navigation..@
Summary: Can't create dependent entity, case id class-id class, @unable to find naviga...
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: JSF (show other bugs)
Version: 7.0
Hardware: PC Other
: P3 normal (vote)
Assignee: Martin Fousek
URL:
Keywords:
: 190524 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-09-22 10:47 UTC by Sergey Petrov
Modified: 2016-07-07 08:55 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
sample project with entities (49.10 KB, application/zip)
2010-09-22 10:48 UTC, Sergey Petrov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Petrov 2010-09-22 10:47:42 UTC
Derived ids sample with id class on parent and id class in dependent entity, generate jsf from entity, try to create dependent and have ejb exception.

Caused by: java.lang.IllegalArgumentException: You have provided an instance of an incorrect PK class for this find operation.  Class expected : class newpackage.EmployeeId, Class received : class java.lang.String.
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.findInternal(EntityManagerImpl.java:647)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:581)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:460)
	at com.sun.enterprise.container.common.impl.EntityManagerWrapper.find(EntityManagerWrapper.java:309)
	at sb.AbstractFacade.find(AbstractFacade.java:37)

it may mean session bean controller isn't valid in this case.
Comment 1 Sergey Petrov 2010-09-22 10:48:54 UTC
Created attachment 102115 [details]
sample project with entities
Comment 2 Sergey Petrov 2012-11-21 14:40:51 UTC
issus is valid yet, but fails with similar error on attempt to 'show all...'
Comment 3 Sergey Petrov 2012-11-21 14:50:58 UTC
*** Bug 190524 has been marked as a duplicate of this bug. ***
Comment 4 Sergey Petrov 2014-01-31 16:18:46 UTC
next patch may be a fast fix to generated controllers
but I don't like '#' usage as a separator, a better solution is required for general purpose instead of simple workaround (exact lines may be different, but it shows main idea), the issues seems to have no problem with derived ids usage but something with composite key with idclass usage.

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- <html>EmployeeWithClassController.java (<b>Today 8:05:37 PM</b>)</html>
+++ <html><b>Current File</b></html>
@@ -188,7 +188,7 @@
         return JsfUtil.getSelectItems(ejbFacade.findAll(), true);
     }
 
-    public EmployeeWithClass getEmployeeWithClass(java.lang.String id) {
+    public EmployeeWithClass getEmployeeWithClass(EmployeeId id) {
         return ejbFacade.find(id);
     }
 
@@ -205,15 +205,17 @@
             return controller.getEmployeeWithClass(getKey(value));
         }
 
-        java.lang.String getKey(String value) {
-            java.lang.String key;
-            key = value;
+        EmployeeId getKey(String value) {
+            java.lang.String[] ke=value.split("#");
+            EmployeeId key = new EmployeeId();
+            key.setFirstName(ke[0]);
+            key.setLastName(ke[1]);
             return key;
         }
 
-        String getStringKey(java.lang.String value) {
+        String getStringKey(java.lang.String value, String value2) {
             StringBuilder sb = new StringBuilder();
-            sb.append(value);
+            sb.append(value).append("#").append(value2);
             return sb.toString();
         }
 
@@ -224,7 +226,7 @@
             }
             if (object instanceof EmployeeWithClass) {
                 EmployeeWithClass o = (EmployeeWithClass) object;
-                return getStringKey(o.getFirstName());
+                return getStringKey(o.getFirstName(), o.getLastName());
             } else {
                 throw new IllegalArgumentException("object " + object + " is of type " + object.getClass().getName() + "; expected type: " + EmployeeWithClass.class.getName());
             }
Comment 5 Sergey Petrov 2014-01-31 16:55:23 UTC
suppose it's better to continue evaluation on jsf side and if jsf generator can't get some necessary information to recognize composite key in this case, in this case apply additional fix on persistence side.
Comment 6 Sergey Petrov 2014-02-10 19:01:26 UTC
After some evaluation: FromEntityBase and may be controller.ftl have no proper handling for idClass, but it seems a bit risky to fix it now, as even if I change wrong definition of idClass from a getter to annotation based, it rrequire update in more places
Comment 7 Martin Balin 2016-07-07 08:55:40 UTC
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