-->
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.  [ 2 posts ] 
Author Message
 Post subject: Overriding validation annotations
PostPosted: Mon Jul 23, 2007 5:06 pm 
Newbie

Joined: Tue Jan 11, 2005 10:52 pm
Posts: 8
Hibernate version: 3.2.4.sp1

I have a simple entity hierarchy:

Code:

abstract class Entity {
...
}

abstract class NamedEntity extends Entity {
  protected String name;

  @Column(name = "name")
  @NotEmpty @Length(max=32)
  public String getName() {
    return name;
  }

}

class ANamedEntityImpl extends NamedEntity {

  @Override
  @Length(max=50)
  public String getName() {
    return name;
  }

}



I want to effectively override the @Length annotation for the name property in ANamedEntityImpl. What is the desired way to do this? Do I have to override the method in order to put an overriding @Length annotation as is the case in the code block above?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 25, 2007 1:24 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There is no way to override. The rational is that if a constraint is applied to a method, all submethods should follow at least the same constraint, because a submethod is just a clarification of a given method, it should not change its behavior

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.