-->
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.  [ 1 post ] 
Author Message
 Post subject: manyTomany self relation problem (ORA-00918: column ambig)
PostPosted: Sun Aug 30, 2009 10:30 am 
Newbie

Joined: Sun Aug 30, 2009 10:07 am
Posts: 3
hi
i have a class named Activity it has a many to many self relation
my annotation is as fallow:

@Entity
@Table(name = "Activity")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING)
@javax.persistence.SequenceGenerator(
name = "SEQ_Activity",
sequenceName = "SEQ_Activity",
allocationSize = 1)

public class Activity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_Activity")
@Column(name = "id")
private Long id;

@ManyToMany(targetEntity = Activity.class)
@JoinTable(name = "prerequisiteactivity",
joinColumns = {@JoinColumn(name = "act")},
inverseJoinColumns = {@JoinColumn(name = "pre")})
private Set<Activity> prerequisiteActivity = new HashSet<Activity>();

@ManyToMany(targetEntity = Activity.class, mappedBy = "prerequisiteActivity")
private Set<Activity> postRequisiteActivity = new HashSet<Activity>();
}

when i try to query my Activity class by ristriction on prerequisiteActivity & postRequisiteActivity
i get the "ORA-00918: column ambiguously defined" exception
the select statemnt generated by hibernate is like this

select * from (select
...
prerequisi60_.act as act,
activity33_.id as pre,
...
postrequis49_.pre as pre,
activity36_.id as act,
...
from from Activity this_ ...
inner join prerequisiteactivity prerequisi60_ on this_.id=prerequisi60_.act
inner join Activity activity33_ on prerequisi60_.pre=activity33_.id
inner join prerequisiteactivity postrequis49_ on this_.id=postrequis49_.pre
inner join Activity activity36_ on postrequis49_.act=activity36_.id
where ... ) where rownum <= ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.