Persist an entity inside itself

Hi all,

I have an entity called Document and I want to create some processes inside a validate method, and one of the things it does, is to set a value of itself

This method will do some things (create and modify other entities) and so on… using DataManager bean to commit them all is ok. Problem is I don’t know how to commit the main entity who started it all and, because right now I’m calling this validate() method from a button on a screen, If I cancel the form, data modified in Document is not saved. Probably injecting datamanager on screen controller and a dm.commit(getItem()) solves it, but not sure if this is what I have in my mind.

I ask for help here because maybe I’m not looking into this problem with the correc eyes. Maybe influenced during my time developing with Smalltalk and OOP, the entity is responsible to do his stuff, and save it. This way, I, or other developer, has not to worry about to persist or not to persist, and/or maybe he don’t knows he has to persist this entity after this process. An entity should be responsible about how to do his business.

Do you mean something like this.commit()?