-->
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.  [ 3 posts ] 
Author Message
 Post subject: Repeated column in mapping for entity
PostPosted: Wed Sep 30, 2009 4:34 am 
Newbie

Joined: Wed Sep 30, 2009 4:23 am
Posts: 3
Hello,

I am trying to do persistence on object A which contains several instances of 2 objects (B & C). B and C have both an attribute of the same name therefore the mapping does not work. Moreover, as there are several instances of B and C, i can't make it work by using the @Column( name="nameB") in B and @Column( name="nameC") in C.

I am trying to prevent this error by using the @AttributeOverrides annotation but I can't make it work.

I know that I could also make it work simply by changing the name of one of the attribute but I would like to do this in a clean way.

Could someone show me a simple example plz ?

Thx
François


Top
 Profile  
 
 Post subject: Re: Repeated column in mapping for entity
PostPosted: Wed Sep 30, 2009 5:17 am 
Newbie

Joined: Wed Sep 30, 2009 4:23 am
Posts: 3
What I did is :

Classe B
Code:
@Embeddable
public class B implements Serializable {

    @Column(name="NUMERO")
    private Integer numero;

setter & getter...
}


Classe C
Code:
@Embeddable
public class C implements Serializable {

    @Column(name="NUMERO")
    private Integer numero;

setter & getter...
}


class A
Code:

@Embedded
@AttributeOverrides( {
            @AttributeOverride(name="numero", column = @Column(name="NUMERO_1") )
    } )
    private B B1;


@Embedded
@AttributeOverrides( {
            @AttributeOverride(name="numero", column = @Column(name="NUMERO_2") )
    } )
    private B  B2;


@Embedded
@AttributeOverrides( {
            @AttributeOverride(name="numero", column = @Column(name="NUMERO_3") )
    } )
    private C  C1;



But it does not work... still the same error about NUMERO .

Anyone can help plz ?


Top
 Profile  
 
 Post subject: Re: Repeated column in mapping for entity
PostPosted: Wed Sep 30, 2009 6:22 am 
Newbie

Joined: Wed Sep 30, 2009 4:23 am
Posts: 3
one should had in B & C
Code:
@Column(name="NUMERO" , insertable=false, updatable=false)


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