Spring Roo: fill a new entity instance with initial data?
-
03-12-2019 - |
Question
I want to fill a new entity with auto generated data. For instance, I want to fill an entity field with a unique token. I'm thinking that this could be done in the constructor on the domain object.
To my suprise I can't find a constructor for the domain/entity classes generated by Roo. Do I break any guidelines by introducing a constructor myself? Or should I instead push in the persistency stuff from MyClass_Roo_Entity.aj and do it there? Thanks in advance!
Solution
I don't know if it's kosher or not, but here's how I ended up doing it.
- Created a no-arg constructor, as suggested here.
- Added the necessary initialization in the constructor.
Seems to work perfectly well.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow