debuglevel / walkingdinner

Genetic Algorithm based tool to generate a plan for a running dinner
The Unlicense
0 stars 0 forks source link

Backend: Generate @ID on our own instead with Hibernate #54

Open debuglevel opened 2 years ago

debuglevel commented 2 years ago

See also https://github.com/debuglevel/greeting-microservice/issues/23

After implementing hashCode() and equals() for all @Entitys we must admit: Most values might change over time - i.e. making them useless for usage in hashCode() (if they change, the hashcode changes and HashSets will not find them anymore). But also there often are just no attributes which are "natural keys" (i.e. the will not change) and could be used (what Hibernate and other documentation often suggests). This would make the id the only attribute which could be used - but is null if not yet persisted.

Ergo: We must set an UUID ourselves as soon as possible and just use this UUID in hashCode (end equals()).