Project: Birt
Bug 129547 [hashcode/equals] add preference for instanceof [code generation]
Reported: 2006-02-27 06:03:12 | Status: verified fixed

Hibernate can load a POJO from a DB. However, it instanciates a proxy class instead of the real POJO class. This allows it to lazily load the attributes when a getter is invoked. However, if equals() or hashCode() is called before any of these getters is called, then the attribute values are null or 0. If there was an option (yes, I hate these as much as the next person) to use getter methods instead of direct access to the data members, that would be great. There is still a problem for these Hibernate/EJB3 pojos. The equals() code uses getClass() == other.getClass(). Because other is a proxy, this always fails. I have read all the discussion about this in JavaLobby, and I understand the reasons for doing this, but for my hibernate objects, I must change it to using instanceof. Again, I would be happy with an option in the generate dialog.

Files changed in fix:
UI/org.eclipse.birt.report.designer.core/src/org/eclipse/birt/report/designer/core/commands/CreateCommand.java UI/org.eclipse.birt.report.designer.ui.lib/src/org/eclipse/birt/report/designer/internal/lib/editparts/LibraryReportDesignEditPart.java UI/org.eclipse.birt.report.designer.ui.lib/src/org/eclipse/birt/report/designer/internal/lib/palette/LibraryTemplateTransferDropTargetListener.java UI/org.eclipse.birt.report.designer.ui/src/org/eclipse/birt/report/designer/internal/ui/editors/schematic/tools/ReportCreationTool.java