Instead of using a constant value for a hash code (which completely forfeits any performance advantage of HashSet and HashMap), you can use a UUID as an ID which is generated in the constructor, instead of a database-assigned ID. Also, this avoids the problem that all entities of the same class will be equal(...) to one another (!!) until they are saved to the database for the first time.
@@theLoneCodesman the UUID can be used as primary key in a database. There are some major advantages, but also some drawbacks. There are many layers to this topic.
Could you mention a case where an entity should be stored in a collection before persisting? Is it reasonable to prohibit non-persisted entities' usage in such cases?
A year ago I decided to try Kotlin and Spring Data JPA. How I wish this video was made avaliable sooner. Would have saved me hours of google time.
JPA Buddy it's awesome!
Immensely useful information here. Thanks a lot guys!
Очень полезное видео, спасибо!:)
exelent video, i wasn't aware of those cases at all
New to Kotlin. Slowly understanding Kotlin for server side 🙏🏽
Instead of using a constant value for a hash code (which completely forfeits any performance advantage of HashSet and HashMap), you can use a UUID as an ID which is generated in the constructor, instead of a database-assigned ID. Also, this avoids the problem that all entities of the same class will be equal(...) to one another (!!) until they are saved to the database for the first time.
Thank you!
Thanks. But are you suggesting that UUID should be saved as a primary key in DB or some arbitrary column or even don’t get persisted at all?
@@theLoneCodesman the UUID can be used as primary key in a database. There are some major advantages, but also some drawbacks. There are many layers to this topic.
@@AlanDarkworld I’m going to google it up. Thanks for pointing it out
Could you mention a case where an entity should be stored in a collection before persisting? Is it reasonable to prohibit non-persisted entities' usage in such cases?
Thanks
Welcome
🙌😀
just dont put entitties to hasmap