-->
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.  [ 3 posts ] 
Author Message
 Post subject: "id" doesn't work, is this a bug?
PostPosted: Fri Dec 08, 2006 7:00 pm 
Newbie

Joined: Sun May 15, 2005 1:24 pm
Posts: 11
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!


Last edited by wildleaf on Fri Dec 08, 2006 8:46 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 08, 2006 8:32 pm 
Newbie

Joined: Sun May 15, 2005 1:24 pm
Posts: 11
I found if I use properties other than "id", for example "name", it works.

Is that a bug??


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 09, 2006 12:19 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
post your mappings please.

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.