I have an entity which needs to be initialized. During initialization I need to access some child elements of a one-to-many association. Unfortunately this association cannot be accessed within the constructor of the entity as it has not been properly processed by the ObjectManager.
What do you mean by "initialize" and by "processed by the ObjectManager"?
And entity is just a regular Delphi class, it doesn't have any information about the entity or its persistence. A class can be created by the manager automatically when it's loaded from the database, or it can be created directly by the user and then "added" to the manager when the object is saved (inserted), or even updated.
assume I have a delphi class "TTest" and I retrieve it through ObjectManager.Find. In this case the ObjectManager will create an instance of TTest and populate its fields with the content loaded from the database. I would like to have an event which is fired after an entity has been intantiated (in case of using Find only when it is not present in the cache). Similar to the possibility of using events with OnUpdating and OnInserting (either as a method call from the object manager or as a method within TTest using an annotation).
This would have two benefits for me:
I can run code after creation of an entity I cannot add to the constructor (e.g. code which needs access to the populated data which is set by the objectmanager after the constructor has been called).
I can store a reference to the ObjectManager within my instance of TTest. In this case my object knows which ObjectManager it belongs to.
It could be an event which is fired when a transient object becomes persistent.