-->
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: How to make a join using hibernate based on id's list
PostPosted: Mon Nov 29, 2010 8:51 am 
Beginner
Beginner

Joined: Wed Nov 03, 2010 1:05 pm
Posts: 24
Hello all,

I have a question regarding join between 2 entities using hql.

Starting on a userProfile, I have to retrieve the name of the role associated to this userProfile. So I need to make a join in order to get it in the role table.

I have the following class UserProfile :

Code:
@Entity
@Table(name="USER_PROFILES")
public class UserProfile extends VersionedObject implements Serializable {

  public static final int CAID_LENGTH = 64;

  @Column(nullable=false, length=CAID_LENGTH)
  private String caid;

  @Column(length=255)
  private String description;

  @CollectionOfElements
  @JoinTable(
      name="USER_ROLES",
      joinColumns={
          @JoinColumn(name="user_id", referencedColumnName="id"),
          @JoinColumn(name="user_v_no", referencedColumnName="v_no")
  })
  @Column(name="role_id")
  private Set<Integer> roleIds;


Here is the Role.java class:

Code:
@Entity
@Table(name="ROLES")
public class Role extends VersionedObject implements Serializable {

  @Column(nullable=false, length=255)
  private String name;
  @Column(length=255)
  private String description;

  @CollectionOfElements
  @JoinTable(
      name="ROLES_RIGHTS",
      joinColumns={
          @JoinColumn(name="role_v_no", referencedColumnName="v_no"),
          @JoinColumn(name="role_id", referencedColumnName="id")
  })

  private Set<Right> rights;



Do you know how can I make a join based on the private Set<Integer> roleIds within the userProfile.java to retrieve the associated role in order to retrieve the name?

doesn't matter if it's using criteria or hql.

Thank you very much :)


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.