-->
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: Duplicate property error
PostPosted: Fri Aug 07, 2009 9:48 am 
Newbie

Joined: Fri Aug 07, 2009 9:21 am
Posts: 4
Hello!

First of all excuse me for my english, it's not very good.

I have a super class named say A with the @MappedSuperclass annotation, and i have a class named say B which extends A.

In class A i have defined a field named profession, which returns a Person, it's as follows:

Code:
@MappedSuperclass
public class A {

@JoinColumn(name="profession")
@ManyToOne(optional=false) 
private Person profession;

public Person getProfession() {
return profession;
}

}


In class B, which extends A, i need to overwrite field profession so it returns a Doctor instead a Person, as follows:

Code:
public class B extends A {
@JoinColumn(name="profession")
@ManyToOne(optional=false) 
private Doctor profession;

public Doctor getProfession() {
return profession;
}

}


As you can imagine, Doctor extends Person.

So far so good, the problem appears when i run my application, i get a message in my Tomcat logs saying:

Quote:
Caused by: org.hibernate.MappingException: Duplicate property mapping of profession found in org.admon.db.bienes.modelo.DesincorporacionInmuebles


It is like i can not overwrite a field defined in the super class, because it says i have a duplicate property.

Am i doing something wrong?

I hope i was clear, and again, sorry if my english is not that good.

Thanks in advance for your time.
Regards!


Top
 Profile  
 
 Post subject: Re: Duplicate property error
PostPosted: Wed Aug 12, 2009 9:21 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
You've got the same variable name in two classes. You'll need to give the property a different mechanism for mapping it to a database row with a different name.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.