In the SymfonyCat, @beberlei, presents an awesome talk about how to deal with few use cases using doctrine, like EAV, see: Doctrine ORM and NoSQL.
MySQL introduces json data type in 5.7.8 witch its similar to a primitive NoSQL.
Lets see how it works in the real life:
Each transaction has his own custom details and this can be stored as json_array in doctrine but at the end you'll have an array soup. Instead of that, we'll use the json data type and create our custom data types. Think simple: An object that serializes into json and the inverted direction. We'll say doctrine how to convert this json into the object we want and when. So, lets go:
Create a Custom type
Create a new custom type its easy, see here. Create a new JsonDocumentType.
Now we'll use this Type to convert DepositDetails into a doctrine custom data type, its a symfony application so add the doctrine mapping into Bundle boot method, by that way you can easily inject the serializer via contianer.
And last step its tell doctrine when to use it, on Deposit doctrine mapping.
Repeated the process with the rest of the transaction types, now its time see the results, for example, a rollback withdrawal scenario.
To use the MySQL JSON functionsin DQL I found: https://github.com/SyslogicNL/DoctrineJsonFunctions
So we did it and its works, so just say thanks to beberlei for his great talk.