Hi Bruno,
We're saving the attachment first because the persistence API lacks any concept of transaction, which means that:
1. If you save the attachment first, the form data next, if that last step fails you might end up with an attachment that isn't referenced from anywhere. This just uses unnecessary space in your database, which could be freed easily, so isn't a huge problem.
2. If you save the data first, and attachments next, you might end up with data that is missing its attachments in the database.
Having some kind of support for transactions, or sending the data and the attachments in one query would be better, but it would also make things more complicated, so, for the time being, we went with option 1 as it creates less problems than option 2. Does that make sense?
Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet