« Return to Thread: Search by ID java.lang.ClassCastException

RE: Search by ID java.lang.ClassCastException

by ghachey :: Rate this Message:

Reply to Author | View in Thread

Hey Ken,

>At first glance I would refrain from using EqualsBuilder.reflectionEquals(this, obj);
> within your equals method. Don't recall but a bit back I ran into a problem operating that.

Yeah I usually don't use it.  I just tried this once.

>Also, might want to try setting your id to null instead of 1L... just to try and shake it out. Shouldn't really have to set it to >anything, although someone picky will shout up some best practice, it don't really matter.

I had tried that but did not make any difference.

>I used Integer for my ID's within the roster demo. And I highly suggest you refer to the same demo for canonical usage >of ID's, equals and hashcode for your domain objects.

The only reason I went with Long was that this project is a port of an existing database and for some reason they have insanely huge IDs.  However, it'll be a while before it reaches the Integer limit so I went back to using Integer.  I don't get the error message anymore so thats good but still don't have an understanding of the problem I had unfortunately.  Ha well...

Thanks,

--
GH

 « Return to Thread: Search by ID java.lang.ClassCastException