Sometimes you have a huge entity with numerous fields and it would be nice to split up the entity into separate classes to handle the complexity.
Say I have a table Foo with columns
someStuff, aThingBlah, aThingEtc, bThingWhatever, bThingBacon
and this class (annotations left out)
class Foo {
String someStuff;
String aThingBlah;
String aThingEtc;
String bThingWhatever;
String bThingBacon;
}
I’d like to refactor this (without changing the db table) to
class Foo {
String someStuff;
AThing aThing;
BThing bThing;
}
class AThing {
String blah;
String etc;
}
class BThing {
String whatever;
String bacon;
}
Is it possible to do this and how?
Here’s the basics…