Hi!
I posted this same comments at the
In Relation To... but then I realized this was a better place for them (so, I apologize for posting them twice) :
What if I need to run a JPAQL query to find out if my object is valid (for example look in a zip-code table mapped by one of my POJO classes) how can I reach the EntityManager from inside the Validator? (
Please don't just tell me "that is a bad practice", I think this validation framework should be able to set a standard way to validate persistent objects, and for that you need to do queries, perhaps not inside you entity pojos, but you need to do them somewhere, and it is better if the place to do that is standarized)
Not all validations need to be checked for the same persistences operation, some should be checked for INSERT, some for UPDATE and some others for DELETE: How do I specify that want to validate, by running a query, before delete? (For example, you can not delete a Customer that still owes some Payments because of the Orders he made in your internet shop)
How can I generate detailed error messages for Class-level constraints, currently it seems I can only say it is valid or it not valid but it doesn't allow to expose contextual information explaining why it is not valid or if it was found to be invalid on INSERT, UPDATE or DELETE?. (It seems I can extract some contextual information from the properties of the annotations, but, what if I want to get some information from the database and show it my error message?) Something like: You cannot buy this {bike} because it costs {1000} and your available credit is {950} (The name of the thing I am trying to buy and its cost and in the "Merchandise" entity, but my available limit need to be re-calculated each time by querying the "Account" entity and my previous still unpaid "Orders")
Thanks,
Regards,