-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: removing inherited annotations
PostPosted: Thu Apr 03, 2008 8:05 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
from spec draft 1.0.Beta1:
Quote:
Constraints declared on a superclass getter will be validate along with any constraints defined on an overridden version of the getter.


Is it really needed to do this?

The proposed spec is giving a good advice, as I expect this to be usually correct, but in case I wanted to remove a validator in an ovverriden getter I can't, there would be no way to get rid of them.

I don't think people ovverride properties in entities very often, but in case someone had to override the method body he might want to override the annotations too; he would be 100% blocked.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2008 8:42 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
What would be the alternative you propose? duplication?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2008 8:45 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The reason the spec is written like that is because from a OO point of view, this is the right thing to do.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 04, 2008 6:54 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi Emmanuel,
Quote:
What would be the alternative you propose? duplication?

I don't like it either, but at least you get some choice.
Quote:
The reason the spec is written like that is because from a OO point of view, this is the right thing to do.

I agree with you that this would be needed for clean code, I am just arguing that maybe you are enforcing a best practice.
Maybe it's a good thing, but if someday someone needs otherwise he will be stuck. Also in OO you you may override a method with a "throw new UnsupportedException", quite ugly but permitted.

I think it should be the default behavior, but you could consider a way to optionally disable it.

What about an annotation similar to
Code:
java.lang.annotation.Inherited
?
You add a new "marking annotation", then you could add it to all default validators and recommend it to be used on all user-provided validator.

You could also make a default wrapping validator which is not marked, so people could "wrap" standard validators to disable inheritance; something like the "@Properties" in your examples but accepting a single validator instead of an array.

regards,
Sanne


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 04, 2008 8:06 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
quoting myself:
Quote:
make a default wrapping validator

I'm sorry I tried to implement a prototype and didn't manage to implement the wrapping validator, I wonder if it's possible;
I'm not an annotations expert, but it looks like I can't wrap another annotation without binding a specific one.
Is there any known trick for that? Would it be possible with WebBeans?

Anyway just adding the marking annotation could give enough flexibility.

Sanne


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 07, 2008 4:33 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
not the wrapper is not doable in Java.

I am thinking that a property level @StopValidationInheritence might do the trick.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 07, 2008 5:04 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
You're right I was thinking of marking the annotations, but you get much better decoupling and flexibility marking the property.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.