Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Cascaded validation in inheritance hierarchy rule too strict
PostPosted: Wed May 27, 2015 4:50 am 
Newbie

Joined: Wed May 27, 2015 4:35 am
Posts: 1
The spec says:

Quote:
One must not mark a method return value for cascaded validation more than once in a line of a class hierarchy. In other words, overriding methods on sub types (be it sub classes/interfaces or interface implementations) cannot mark the return value for cascaded validation if the return value has already been marked on the overridden method of the super type or interface.


My understanding of this requirement is that it is guaranteed this way that an overridden method in a subtype won't put a weaken set of constraints on the value returned from the method. The guarantee is reasonable though the way it is enforced is in my opinion too strict.

Consider the following example. An overridden method also marks the return value for cascaded validation and defines a strict superset of constraints defined on the supertype method. This way the requirement for not weakening the postconditions in a subtype still holds yet this example is explicitly prohibited by the current spec wording.

Instead of the current wording the spec should probably say that an overriden method in a subtype may mark the return value for cascaded validation if
  • the return value has not already been marked on the overridden method of the super type or interface, or
  • the return value has already been marked on the overridden method of the super type or interface and the set of constraints in the overriding method is not a strict subset of constraints defined by the superclass method.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.