I want to get all events in which user participate. My HQL for it is: from Event e join e.participantsList u where u.userid=:fuserid but it does not work...help please,pretty please with sugar on top :)
@Entity public class Event { private long eventID; private Collection<UserData> participantsList; @Id @GeneratedValue() public long getEventID(){return eventID;} public void setEventID(long eventID){this.eventID = eventID;} @ManyToMany(cascade = CascadeType.ALL,fetch=FetchType.EAGER) @JoinTable(name = "event_userdata",joinColumns={@JoinColumn(name = "eventID")},inverseJoinColumns={@JoinColumn(name = "userID")}) public Collection<UserData> getParticipantsList(){return participantsList;} public void setParticipantsList(Collection<UserData> participantsList){this.participantsList = participantsList;} }
@Entity @Table(name="USERDATA") public class UserData { private long userID; private String nickname;
@Id @Column(name="USERID") @GeneratedValue public long getUserID(){return userID;} public void setUserID(long userID){this.userID = userID;} @Column(name="NICKNAME") public String getNickname(){return nickname;} public void setNickname(String nickname){this.nickname = nickname;} }
Tables in db: event(eventid) userdata(userid,nickname) event_userdata(eventid,userid)
|