-->
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.  [ 2 posts ] 
Author Message
 Post subject: Component and association
PostPosted: Tue Aug 08, 2006 5:23 pm 
Newbie

Joined: Fri Feb 10, 2006 2:20 pm
Posts: 9
Hibernate version: 3.2-cr2
Annotations: 3.2.0-CR1

Here is my model: a User doesn't contain directly his roles but it has a component AccessInfo with these roles. But the Role refers to User...

Code:
@Entity
public class User {
  private AccessInfo accessInfo;
  [...]
}

@Embeddable
public class AccessInfo {
  @ManyToMany
  @JoinTable(name = "user_role", joinColumns = { @JoinColumn(name = "userId") }, inverseJoinColumns = { @JoinColumn(name = "roleId") })
  private Set<Role> roles;
  [...]
}

@Entity
public class Role {
  @ManyToMany(targetEntity = User.class, mappedBy = "accessInfo.roles")
  @JoinTable(name = "user_role", joinColumns = { @JoinColumn(name = "roleId") }, inverseJoinColumns = { @JoinColumn(name = "userId") })
  private Set<User> users;
  [...]
}


My parameter "mappedBy" in the @ManyToMany association in Role is wrong but I don't know how to define it.

I read in the documentation:
Quote:
You cannot use association annotations in an embeddable object (ie no @*ToOne nor @*ToMany). This is disallowed
by the spec, and not yet supported in Hibernate Annotations.

But does this apply to this pattern or to an association of components ?

Do I have an other choice than merge my User and my AccessInfo into a single bean ?

Thanks in advance

Cedric


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 11:22 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Where did you read such a statement?
This should theorically be possible. What is wrong when you do that?

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.