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.
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.
Created attachment 102115 [details] sample project with entities
issus is valid yet, but fails with similar error on attempt to 'show all...'
*** Bug 190524 has been marked as a duplicate of this bug. ***
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()); }
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.
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
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