-->
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.  [ 1 post ] 
Author Message
 Post subject: criteria api join table problem
PostPosted: Thu Sep 02, 2010 8:03 am 
Newbie

Joined: Thu Sep 02, 2010 7:46 am
Posts: 1
Hi,
i cannot use sorting on join tables. Let me explain.

i have three tables. users, roles and user_roles.
my entities are User, UserRole, UserRolePK, Role.

Code:
|User    |     | UserRole |     | UserRplePK |     | Role |
|--------|     |----------|     --------------     --------
|id      |     | pk       |     | user       |     | id   |
|name    |                      | role       |     | name |


this is what i wanted to:
"SELECT * FROM user_roles ur JOIN users u ON u.ID = ur.UserID ORDER BY u.name;"

Code:
    CriteriaImpl criteria = (CriteriaImpl) session.createCriteria(UserRole.class);
    criteria.addOrder(Order.asc("pk.user.name"));
    List userRoles = criteria.list();


The error is
could not resolve property: pk.user.name of: models.UserRole


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.