0

I have a C parent class and a PC child class which adds temporary metadata. I want to persist PCs as Cs (discarding the extra data from PCs). Despite casting, eBean outsmarts me and figures out that it really has a PC, not a C. What is the best way to address this situation?

Some things I've considered:

  • Making a "toC" method in PC, which makes a fresh instance of C. This will make updates to C dangerous, though, as they'll require updates to "toC".
  • Use reflection in some way to copy all of the fields in PC to a fresh C.
  • Tell eBean that it should persist all PCs as Cs. I can't figure out how to do this.

Thanks for any insight.

timfreilly
  • 966
  • 1
  • 9
  • 11

1 Answers1

0

My current solution (to my own problem) is to use BeanUtils.copyProperties, which I learned about here: Copy all values from fields in one class to another through reflection

Community
  • 1
  • 1
timfreilly
  • 966
  • 1
  • 9
  • 11