I'm CCing Emmanuel Bernard answer :
*"Two quick remarks.*
*
*
*If you plan on adding method validation, make it enabled by default.
That's the strategy we have used for CDI and JAX-RS. We have an annotation
to disable it if necessary.*
*
*
*What would be a concrete use case to validate an EJB during the remove or
destroy state changes? What should the system do if an error happens?"*
On Thu, Aug 30, 2012 at 1:46 PM, Emmanuel Bernard <emmanuel_at_hibernate.org>wrote:
> - Please CC the jsr-345 mailing list if your list does not allow non
> member posts. I'm not registered -
>
> Two quick remarks.
>
> If you plan on adding method validation, make it enabled by default.
> That's the strategy we have used for CDI and JAX-RS. We have an annotation
> to disable it if necessary.
>
> What would be a concrete use case to validate an EJB during the remove or
> destroy state changes? What should the system do if an error happens?
>
>
> On 30 août 2012, at 09:41, Antonio Goncalves wrote:
>
> In JPA BV is set by default (during @PrePersist @PreUpdate & @PreRemove).
> You can always change this default behavior. I would expect BV to work the
> same way in the entire EE platform, i.e. method-level validation should be
> set by default. But not just on EJBs, I would say on all ManagedBeans. Now
> that transactions can be used in ManagedBeans, they can act as a service
> façade, so I would like something like this to work out of the box :
>
> @RequestScoped
> @Transactional
> public class AccountService {
>
> public Account get(@NotNull Account model) { }
> }
>
>
> Even on Rest and SOAP web services
>
> @Path
> @Transactional
> public class AccountService {
>
> public Account get(@NotNull Account model) { }
> }
>
> @WebService
> @Transactional
> public class AccountService {
>
> public Account get(@NotNull Account model) { }
> }
>
> As for validating beans on @PreDestroy, I'm not totally sure. Emmanuel
> Bernard (cc) explained why it was important to validate an entity at
> @PreRemove (
> http://in.relation.to/Bloggers/WhyCanICallBeanValidationWhenIRemoveAnEntityInJPA2)
> (i.e it makes sense to unable deleting a bill if the status is not payed).
> But I can't see a use case for that on @PreDestroy
>
> Antonio
>
> On Wed, Aug 29, 2012 at 11:17 PM, Marina Vatkina <
> marina.vatkina_at_oracle.com> wrote:
>
>> Jean-Louis, Experts,
>>
>> Should method validation be available by default? Or will it need to be
>> opt-in (and opt-out)?
>>
>> thanks,
>> -marina
>>
>> Jean-Louis MONTEIRO wrote:
>>
>>> Hi,
>>>
>>> Yes, agree with Antonio.
>>> Method level validation was optional and is now part of BV 1.1.
>>> It should work out of the box with or without CDI.
>>>
>>> As an example, we already have it out of the box in OpenEJB and it's
>>> useful.
>>>
>>> Here is an example
>>> http://openejb.apache.org/**examples-trunk/bean-**
>>> validation-design-by-contract/<http://openejb.apache.org/examples-trunk/bean-validation-design-by-contract/>
>>>
>>> So, +1 to support BV for method level validation
>>>
>>> Jean-Louis
>>>
>>>
>>>
>>> 2012/8/29 Antonio Goncalves <antonio.goncalves_at_gmail.com <mailto:
>>> antonio.goncalves@**gmail.com <antonio.goncalves_at_gmail.com>>>
>>>
>>>
>>> Hi all,
>>>
>>> With the new Bean Validation 1.1 method-level validation I expect
>>> something to work out of the box (with or without CDI) :
>>>
>>> @Stateless
>>> public class AccountService {
>>>
>>> public Account get(*_at_NotNull* Account model) { }
>>>
>>> }
>>>
>>>
>>> As for Stateful bean the question is "is there a possible
>>> integration between BV and EJB like JPA or JSF" ? For example, in
>>> the following code, shall we automatically validate the bean on
>>> @Remove (like @PreRemove on JPA) :
>>>
>>> @Stateful
>>> public class ShoppingCart {
>>>
>>> *_at_NotNull*
>>> private List<CartItem> cartItems;
>>>
>>> *_at_Remove*
>>> public voide checkout { // validate cartItems ? }
>>> }
>>>
>>> I don't really see the point in something like that, but I might
>>> miss something. Could there be another possible integration ?
>>>
>>> Antonio
>>>
>>> On Wed, Aug 29, 2012 at 12:41 AM, Marina Vatkina
>>> <marina.vatkina_at_oracle.com <mailto:marina.vatkina_at_oracle.**com<marina.vatkina_at_oracle.com>>>
>>> wrote:
>>>
>>> Experts,
>>>
>>> As you know, EJB spec currently doesn't support Bean
>>> Validation. Do we want to change that?
>>>
>>> Let me know if you think that:
>>>
>>> a) BV should be supported for EJBs without CDI being enabled
>>> (probably with an opt-in flag to be backward compatible)
>>> b) BV should be supported for EJBs only if CDI is enabled
>>> c) there is no need for standardizing BV with respect to EJBs
>>> d) you don't care either way :(
>>>
>>>
>>> thanks,
>>> -marina
>>>
>>>
>>>
>>>
>>> -- Antonio Goncalves
>>> Software architect and Java Champion
>>>
>>> Web site <http://www.antoniogoncalves.**org<http://www.antoniogoncalves.org/>>
>>> | Twitter
>>> <http://twitter.com/agoncal> | LinkedIn
>>> <http://www.linkedin.com/in/**agoncal<http://www.linkedin.com/in/agoncal>>
>>> | Paris JUG
>>> <http://www.parisjug.org> | Devoxx France <http://www.devoxx.fr>
>>>
>>>
>>>
>
>
> --
> Antonio Goncalves
> Software architect and Java Champion
>
> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>|
> LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/> |
> Devoxx France <http://www.devoxx.fr/>
>
>
>
--
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org> |
Twitter<http://twitter.com/agoncal>|
LinkedIn <http://www.linkedin.com/in/agoncal> | Paris
JUG<http://www.parisjug.org> |
Devoxx France <http://www.devoxx.fr>