-->
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.  [ 5 posts ] 
Author Message
 Post subject: Problem with composite id ... or the understanding of it (?)
PostPosted: Tue Jun 22, 2010 8:09 am 
Newbie

Joined: Fri May 21, 2010 8:37 am
Posts: 14
Rather simple thing realy, but I'm doing something wrong it seems.

Entity A has a Set of AX which has Primary Key A.id and C.id pluss a value :)
Code:
...
@Entity
@Table(name="A")
public class A
{
   
    @Id
    @GeneratedValue(generator="SEQ_FELLES")
    @SequenceGenerator(name="SEQ_FELLES", sequenceName="ODB_FELLES_SEQ", allocationSize=1)
    @Column(name="A_ID")
    private long id;

    @OneToMany(mappedBy="A", fetch=FetchType.EAGER)
    private Set<AX> setOfAX;
...
}


Code:
@Entity
@Table(name="AX")
public class AX
{
   
    @Id
    @ManyToOne
    @JoinColumn(name="A_ID")
    private A aAObj;
   
    @Id
    @ManyToOne
    @JoinColumn(name="C_ID")
    private C aCObj;

    @Column(name="SOME_VALUE")
    private long someValue;
...
}


Code:
@Entity
@Table(name="C")
public class C
{   
    @Id
    @Column(name="C_ID")
    private long cId;

    @Column(name="ANOTHER_VALUE")
    private long anotherValue;
...
}


during initialization I get the Mapping error:
Code:
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: domain.AX.A in domain.A.setOfB


all 3 classes are part of the annotedClasses property (using spring and annotationsessionfactory). If I remove the relation to AX from A (and removing AX from annotedclasses) it works ...

This is probably something simple I am doing wrong or misunderstanding, but I can't seem to wrap my head around what it is :)


Top
 Profile  
 
 Post subject: Re: Problem with composite id ... or the understanding of it (?)
PostPosted: Tue Jun 22, 2010 1:43 pm 
Newbie

Joined: Fri May 21, 2010 8:37 am
Posts: 14
so - is it to simple to deem worthy answering ? ;)

I have a workaround though, just adding a sequence as identifier for the table, but .....
Though I rather not do that if anyone is able to help


Top
 Profile  
 
 Post subject: Re: Problem with composite id ... or the understanding of it (?)
PostPosted: Wed Jun 23, 2010 2:10 am 
Newbie

Joined: Fri May 21, 2010 8:37 am
Posts: 14
oh darn ... no one ? would realy hate to add a sequence to be the PK :(


Top
 Profile  
 
 Post subject: Re: Problem with composite id ... or the understanding of it (?)
PostPosted: Wed Jun 23, 2010 2:25 am 
Newbie

Joined: Fri May 21, 2010 8:37 am
Posts: 14
Not given up just yet, thouigh found this post from 2006 by a hibernate Team member :
viewtopic.php?p=2303272#p2303272
"@ManyToOne and @Id are not supported through annotations so far."

Is still this the case ?


Top
 Profile  
 
 Post subject: Re: Problem with composite id ... or the understanding of it (?)
PostPosted: Wed Jun 23, 2010 4:31 am 
Newbie

Joined: Fri May 21, 2010 8:37 am
Posts: 14
Seems the OneToMany was the issue. When I changed it to
Code:
    @OneToMany(fetch=FetchType.EAGER)
    @JoinColumn(name="A_ID")
    private Set<AX> setOfAX;

it compiles as it should.


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