-->
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: many to many and annotations
PostPosted: Wed Oct 29, 2008 7:01 am 
Newbie

Joined: Wed Oct 29, 2008 6:27 am
Posts: 1
Hi,

I'm totally new to Hibernate and have some trouble creating a many to many association with annotations.

I have two classes User and Department

Code:
@Entity
public class User implements Serializable
{
@ManyToMany(targetEntity =com.test.Department.class)
@JoinTable(
   name="JOIN_USER_DEPARTMENT",
   joinColumns=@JoinColumn(name="ID_DEPARTMENT")
   inverseJoinColumns=@JoinColumn(name="ID_USER"))

  private Collection<Departments> departments; // and get/set methods for this
}


Code:
@Entity
public class Department implements Serializable
{
@ManyToMany(targetEntity =com.test.User.class)
@JoinTable(
   name="JOIN_USER_DEPARTMENT",mappedBy="departments")
}



The code without the many to many association has been up and running without problems.

As soon as I add the association I get this Exception:
Code:
Could not determine type for: java.util.Collection, at table: User, for columns: [org.hibernate.mapping.Column(departments)]


Im not really wondering about the exception because in general I don't understand how this is supposed to work at all.

My guess is that Hibernate tries to map the department attribute to a column in the User table which - of course - does not exist.

Thanks in advance


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.