Hibernate version:3.2.1GA
I have two entities: User and Board. It is ManyToMany relationship between them. I mapped the join table to a collection of components since I need extra column in the relationship table.
In User:
Code:
@CollectionOfElements
@JoinTable(name = "users_boards", joinColumns = @JoinColumn(name = "USER_ID"))
public Collection<UserBoard> getUserBoards() {
return userBoards;
}
In UserBoard:Code:
@ManyToOne
@JoinColumn(name = "BOARD_ID")
public Board getBoard() {
return board;
}
I can create new relationships with no trouble. But when I try to do the following:
Code:
select ub.board.id from User u join u.userBoards ub where u.id=:id
getSession().createQuery(sql) throws this error:Code:
could not resolve property: board.id of: com.thinkubate.board.domain.entity.User [select ub.board.id from com.thinkubate.board.domain.entity.User u join u.userBoards ub where u.id=:id]
But if I use
Code:
select ub.board from User u join u.userBoards ub where u.id=:id
It executes successfully.
Can anybody tell me how can I access "Board" properties in the query?
Thanks a lot!