-->
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: bidirectional many-to-many hibernate HQL query not working
PostPosted: Sun Jan 24, 2010 1:11 pm 
Newbie

Joined: Sun Jan 24, 2010 12:53 pm
Posts: 2
I am trying to fetch data from many-to-many bi direction mapping.
I have three tables: eventdescription, eventtype, and eventtypedescription. eventtype is the joint table of eventdescription and eventtypedescription tables, whose primary key is the foreign key of other two tables.

public class EventDescription implements Serializable {

private Integer eventDescriptionId;
private Set eventType = new HashSet();
.
.
public EventDescription() {}

}
my EventDescription.hbn file is
<class name="EventDescription" table="eventdescription">
<id name="eventDescriptionId" column="eventdescriptionid">
<generator class="native" />
</id>
.
<set name="eventType" table="eventtype" lazy="false">
<key column="eventdescriptionid" />
<many-to-many column="eventtypeid" class="EventTypeDescription" />
</set>

Pojo file
public class EventTypeDescription implements Serializable {

private Integer eventTypeId;
private Set<EventTypeDescription> events;

public EventTypeDescription()
{}
}

EventTypeDescription.hbn file is :

<class name="EventTypeDescription" table="eventtypedescription">
<id name="eventTypeId" column="eventtypeid">
<generator class="native" />
</id>

<set name="events" table="eventtype" inverse="true">
<key column="eventtypeid" />
<many-to-many column="eventdescriptionid" class="EventDescription"/>
</set>

I am not able to fetch data from eventdescription and eventtypedescription tables. If anyone knows please let me know how to write the HQL query to fetch data. I think I have to do join but my join query is not working for the two tables. It is working for one eventdescription table.

Below is the working query:
List<?> result = session.createQuery("FROM EventDescription "").list();

Thanks!!!!


Top
 Profile  
 
 Post subject: Re: bidirectional many-to-many hibernate HQL query not working
PostPosted: Mon Jan 25, 2010 11:40 am 
Newbie

Joined: Sun Jan 24, 2010 12:53 pm
Posts: 2
Can anyone help me for above problem. I am doing my project and due to this problem I am not able to go ahead.

Thank you very much for you answer in advance!!!


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.