-->
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.  [ 4 posts ] 
Author Message
 Post subject: Overriding Annotations in subclasses
PostPosted: Sun Sep 13, 2009 10:10 pm 
Beginner
Beginner

Joined: Thu Feb 21, 2008 3:31 pm
Posts: 34
Hi all,

I have an abstract superclass which has 2 fields:name and description. I use this superclass throughout my application by extending it as needed. My question is, in some of my subclasses, I want to add an annotation or change an annotation:

superclass
Code:
@Column(nullable = false)
public String getName()
{return(name);}



subclass
Code:
@RoleName
@Column(nullable = false, unique = true)
public String getName()
{return(name);}



Is it possible to override the method like that? I am getting this error.

Caused by: org.hibernate.MappingException: Duplicate property mapping of name found in com.walterjwhite.seamCore.model.security.Role

I would like to avoid any sorts of duplication when possible.


Thanks,
Walter


Top
 Profile  
 
 Post subject: Re: Overriding Annotations in subclasses
PostPosted: Mon Sep 14, 2009 12:50 pm 
Newbie

Joined: Mon Sep 14, 2009 12:34 pm
Posts: 4
I think if you specify your super class as a @MappedSuperclass then it may work.


Top
 Profile  
 
 Post subject: Re: Overriding Annotations in subclasses
PostPosted: Mon Sep 14, 2009 1:08 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
I've never personally done it but @AttributeOverride looks like what you might want.

_________________
Some people are like Slinkies - not really good for anything, but you still can't help but smile when you see one tumble down the stairs.


Top
 Profile  
 
 Post subject: Re: Overriding Annotations in subclasses
PostPosted: Mon Sep 14, 2009 10:27 pm 
Beginner
Beginner

Joined: Thu Feb 21, 2008 3:31 pm
Posts: 34
Hi,

Thanks for your suggestion; however, upon looking at the JavaDoc, AttributeOverride only appears to override the column mapping and not the annotations on the superclass.

I simply want to only see the annotations the subclass has on the overridden method.


Walter


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