-->
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.  [ 6 posts ] 
Author Message
 Post subject: How to resolve the "Repeated column in mapping for entity"?
PostPosted: Tue Apr 06, 2010 11:32 pm 
Regular
Regular

Joined: Tue Feb 17, 2009 3:36 pm
Posts: 78
Here is the code:
Code:
@Embeddable
public class Address implements java.io.Serializable {
   private String addr; // Address details
...
}

and
Code:
@Entity
@Table(name = "worker")
public class Worker {

        @Embedded
   private Address homeAddress;

   @Embedded
   @AttributeOverrides( {
         @AttributeOverride(name = "addr", column = @Column(name = "workaddress")),
         @AttributeOverride(name = "city", column = @Column(name = "workcity")),
         @AttributeOverride(name = "country", column = @Column(name = "workcity")),
         @AttributeOverride(name = "phone", column = @Column(name = "workphone")),
         @AttributeOverride(name = "state", column = @Column(name = "workstate")),
         @AttributeOverride(name = "zip", column = @Column(name = "workzip")) })
   private Address workAddress;
        ...

I get an error of "Repeated column in mapping for entity" on addr for various configurations: with/without @Embedded on homeAddress, with/without @AttributeOverrides on the homeAddress. Although the error message also mentions that 'should be mapped with insert="false" update="false"', I don't think it is right for the usage.

How to solve this problem?


Top
 Profile  
 
 Post subject: Re: How to resolve the "Repeated column in mapping for entity"?
PostPosted: Wed Apr 07, 2010 5:17 am 
Beginner
Beginner

Joined: Fri Aug 24, 2007 9:47 am
Posts: 21
I think you need to change the name of the property of your class Address
So :
private String addrDetail;

anyway it's never good to have 2 same property in heritance

_________________
recherche-programmeur.fr


Top
 Profile  
 
 Post subject: Re: How to resolve the "Repeated column in mapping for entity"?
PostPosted: Wed Apr 07, 2010 12:37 pm 
Regular
Regular

Joined: Tue Feb 17, 2009 3:36 pm
Posts: 78
iometrine wrote:
I think you need to change the name of the property of your class Address
So :
private String addrDetail;

Why?
iometrine wrote:
anyway it's never good to have 2 same property in heritance

It is the composition relationship, but not the Inheritance relationship, right?


Top
 Profile  
 
 Post subject: Re: How to resolve the "Repeated column in mapping for entity"?
PostPosted: Thu Apr 08, 2010 8:11 am 
Beginner
Beginner

Joined: Fri Aug 24, 2007 9:47 am
Posts: 21
you're right for inheritance i missed it, so did you try to change the name anyway ?

_________________
recherche-programmeur.fr


Top
 Profile  
 
 Post subject: Re: How to resolve the "Repeated column in mapping for entity"?
PostPosted: Thu Apr 08, 2010 11:02 am 
Newbie

Joined: Tue Mar 23, 2010 9:04 am
Posts: 6
I think you need another embeddable for the work address, you are specifying that the work address and the address will use the same @Column mapping annotation.

AttributeOverrides is used if you have two different tables with address information and the two tables dont use the same column names for the information.

If your Address embeddable type is defaulting to names in TABLE 1, then you can use AttributeOverride to specify the names used in TABLE 2.

If you want a Worker to be associated with two addresses and dont want to supply double mapping, you need to make Address an Entity with its own table and map

Code:
public class Worker {

  @ManyToOne
  private Address address

  @ManyToOne
  private Address workAddress;

}


Top
 Profile  
 
 Post subject: Re: How to resolve the "Repeated column in mapping for entity"?
PostPosted: Thu May 13, 2010 1:36 pm 
Regular
Regular

Joined: Tue Feb 17, 2009 3:36 pm
Posts: 78
FEB wrote:
I think you need another embeddable for the work address, you are specifying that the work address and the address will use the same @Column mapping annotation.

AttributeOverrides is used if you have two different tables with address information and the two tables dont use the same column names for the information.
...


Any document supports the above statement?


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