https://kotlinlang.org logo
#spring
Title
h

hho

05/28/2018, 8:45 AM
You can implement any method in an abstract class ¯\_(ツ)_/¯
z

ziggy42

05/28/2018, 8:47 AM
Yes but why without
equals
and
hashCode
a default constructor was not created?
h

hho

05/28/2018, 8:57 AM
Now I'm confused – does a constructor have anything to do with
equals
and
hashCode
?
z

ziggy42

05/28/2018, 8:58 AM
I don't think so, but it worked. We had an older service with this setup and the only thing I didn't copied from the AbstractEntity was the implementetion for
equals
and
hashCode
, because I thought they were useless since all my entities are gonna be data classes anyway
I tried just because I didn't know what else to try, and it worked
c

Czar

05/28/2018, 1:53 PM
I'd really like to know what's going on there... Seems ridiculous.
a

Allan Wang

05/28/2018, 3:29 PM
I dont use entities, but a quick search did not reveal anything about needing to implement those methods. Are you sure you didn't actually just miss a default constructor before and added it while you added those methods?
z

ziggy42

05/28/2018, 4:14 PM
Yes I'm sure
e

Ed M

05/31/2018, 7:32 PM
Andrea, I’ve noticed before that adding the noarg plugin (or the spring plugin) doesn’t necessarily regenerate your classes in your IDE. By you adding equals and hashcode, you told your IDE to recompile the class, so you got your noarg constructor through that.
👍 1
I would guess that you can remove the equals and hashcode now, and it’ll work 🙂
6 Views