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 218064 - equals inserted into JPA Entities causes errors
Summary: equals inserted into JPA Entities causes errors
Status: RESOLVED DUPLICATE of bug 156994
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.2
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-10 11:14 UTC by mhankus
Modified: 2012-09-11 14:55 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mhankus 2012-09-10 11:14:57 UTC
When generating Entities from New->Persistence->Entity Class, netbeans generates equals using instanceof, but when you generate code later, netbeans generates equals using 
getClass() != obj.getClass()

Second case returns false, if one of objects is proxy (it happens very often when using JPA lazy loading), so equals returns false all the time, and code fails.

This error can appear, when you try to optimize application by annotating some entities as lazy loaded. Application errors start occurring, in unexpected places.

Right now we have to rewrite equals code in all our entities.


Also checking for equals implemented using getClass, when object is annotated with @Entity, could be added as error for code inspector (or hint to source code)
Comment 1 Dusan Balek 2012-09-11 14:55:27 UTC
getClass() vs. instanceof: bug #156994 is mostly about that.

*** This bug has been marked as a duplicate of bug 156994 ***