dierre
06/23/2017, 7:52 AMdata
class to do something like this. And for me it’s actually a good thing, because the bean you use to model your JPA entity should stay inside the JPA module. You have to convert it to a model that makes sense in your domain, and at that point, you can actually use a data class that doesn’t rely on those necessities given by the ORM framework you are using.Czar
06/23/2017, 7:59 AMdierre
06/23/2017, 8:03 AMCzar
06/23/2017, 8:38 AM{"device": { "maker": "Samsung", "released": "2017-06-23" }}
{"mobilePhone": {"maker": "Samsung", "released": "2017-06-23", "ram": "3G" }}
Example is of course very simple, in real life it's much bigger (and not related to Samsung or mobile phones 🙂 ), otherwise I would've just use separate model classes and nvm a little duplication.orangy
06/23/2017, 8:57 AMdata
in your classes?Czar
06/23/2017, 10:43 AMequals
and toString
mostly, of course I can implement that myself, but just wanted to use the built-in if that were possible. componentN
and copy
are also nice-to-haves sometimes, latter e.g. when writing tests.orangy
06/23/2017, 10:44 AMequals
in hierarchies? Also, hashcodeCzar
06/23/2017, 10:50 AMorangy
06/23/2017, 10:51 AMCzar
06/23/2017, 10:52 AMorangy
06/23/2017, 10:54 AMCzar
06/23/2017, 10:57 AMorangy
06/23/2017, 11:04 AMequals
& hashCode
to be symmetric for callers, ie. baseInstance == derivedInstance
, if base is non-abstract. So the code should be checking for a type equality in every equals, but then you can’t delegate from derived equals to base equals because it would fail.data class
🙂copy
, constructors and the most interesting componentN
, which is unclear how to even implement in case of separate compilation – you need some fancy numbering scheme or something.Czar
06/23/2017, 12:40 PM