I am having difficultly overriding an annotated property 'at the Java level'. For example:
Code:
@MappedSuperclass
public abstract class NamedEntity
{
   @NotNull
   @Column( unique = true )
   public String getName()
   {
      return m_strName;
   }
}
@Entity
@Inheritance( strategy = InheritanceType.JOINED )
public abstract class Resource
   extends NamedEntity
{
   @UILabel( "Login" )
   public String getName()
   {
      return super.getName();
   }
}
Here, I have a base class 'NamedEntity' (which is an entity that has a name), and a subclass 'Resource' (which is later further subclassed into 'Staff', 'Client' etc). I need to override the 'Name' property so that I can add a new annotation that displays a slightly different label than 'Name' in the UI (@UILabel being one of my own annotations).
However, Hibernate Annotations always throws a 'duplicate property mapping' exception when I try this. The only way I have found to work around this is to further annotate the overriden property with @Transient, such that:
Code:
   @UILabel( "Login" )
   @Transient
   public String getName()
   {
      return super.getName();
   }
...but this seems very hacky. Is there a better way?
With the increasing prevelance of annotations used for both persistence and UI 'hints', I can see this kind of requirement becoming more and more common.