[jboss-user] [EJB 3.0] - Querying a join table

aidan_b5 do-not-reply at jboss.com
Fri Aug 4 06:56:47 EDT 2006


Hi, I need to query the join table of a many to many relationship and am having trouble.

PersistentValue class:

	@ManyToMany(cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
  | 	@JoinTable(name = "user_filter",
  | 			joinColumns={@JoinColumn(name="persistentvalue_id")},
  | 			inverseJoinColumns={@JoinColumn(name="persistentuser_id")})
  | 	public Collection<PersistentUser> getUsersAllowed() {
  | 		if(usersAllowed == null) usersAllowed = new ArrayList<PersistentUser>();
  | 		return usersAllowed;
  | 	}


PersistentUser class:

	@ManyToMany(mappedBy = "usersAllowed")
  | 	public Collection<PersistentValue> getUserFilters() {
  | 		if(userFilters == null) userFilters = new ArrayList<PersistentValue>();
  | 		return userFilters;
  | 	}


If I try to query user_filters directly, I get a 'no such mapping exception'. Do I need to create an entity representing the join table, and if so, how do i do this?

Your help appreciated, thanks.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3963139#3963139

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3963139



More information about the jboss-user mailing list