querydsl / codegen

Java/Scala Code generation tool
Apache License 2.0
23 stars 22 forks source link

hashCode and equals in model package #12

Closed jendap closed 9 years ago

jendap commented 11 years ago

Is there a reason for hashCode and equals methods in model package to be implemented and yet not using all the fields in the classes?

Would it not be better to either remove them or regenerate them with comparing/hashing all the fields?

It breaks for example scala case class code generation in querydsl. I'm going to work around it there. But it should be fixed here.

timowest commented 11 years ago

Which classes do you have in mind?

timowest commented 11 years ago

The Parameter doesn't use the name field in equals and hashCode on purpose. Could you explain how it is a problem in your case class case?

mdmoss commented 9 years ago

I've just encountered the same issue, using Querydsl to generate Scala case classes. I'll make a PR there for an actual fix, but I've found that this becomes an issue when mapping over a Set[Parameter] to produce a Set[Property]. The resulting set only contains one Property of each type, because of the hashCode collisions.

Specifically, the issue occurs in ScalaBeanSerializer

(And apologies for bumping a dead thread!)