[jboss-user] [EJB 3.0] - unidirectional Many-To-Many relationships

urkens_jp do-not-reply at jboss.com
Mon Apr 16 09:01:04 EDT 2007


When trying to model unidirectional M-t-M relations I get a org.hibernate.MappingException.
I tried the example from Mastering EJB3.0 from Wiley Publishing:


  | @Entity(name="CourseUni")
  | public class Course implements Serializable {
  | 	private int id;
  | 	private String courseName;
  | 	
  | 	private Collection<Student> students = new ArrayList<Student>();
  | 	
  | 	public Course() { id = (int)System.nanoTime();	}
  | 
  | 	@Id
  | 	public int getId() { return id;	}
  | 	
  | 	public void setId(int id) { this.id = id;}
  | 	
  | 	public String getCourseName() { return courseName;}
  | 	
  | 	public void setCourseName(String courseName) {
  | 		this.courseName = courseName;
  | 	}
  | 
  | 	public Collection<Student> getStudents() {
  | 		return students;
  | 	}
  | 
  | 	public void setStudents(Collection<Student> students) {
  | 		this.students = students;
  | 	}
  | }
  | 
  | @Entity(name="StudentUni")
  | public class Student implements Serializable {
  | 	private int id;
  | 	private String name;
  | 	private Collection<Course> courses = new ArrayList<Course>();
  | 	
  | 	public Student() { id = (int)System.nanoTime();	}
  | 	
  | 	@Id
  | 	public int getId() { return id; }
  | 	public void setId(int id) { this.id = id;}
  | 	public String getName() { return name;	}
  | 	public void setName(String name) { this.name = name; }
  | 
  | @ManyToMany(cascade={CascadeType.ALL},fetch=FetchType.EAGER)
  | 	@JoinTable(name="STUDENTUNI_COURSEUNI")
  | 	public Collection<Course> getCourses() {
  | 		return courses;
  | 	}
  | 
  | 	public void setCourses(Collection<Course> courses) {
  | 		this.courses = courses;
  | 	}
  | 
  | 

When deploying this on JBOSS-4.0.5.GA following Exception is thrown:
:49:41,641 DEBUG [org.jboss.ejb3.ServiceDelegateWrapper] Starting failed persistence.units:jar=tutorial.jar,unitName=tempdb
  | javax.persistence.PersistenceException: org.hibernate.MappingException: Could not determine type for: java.util.Collection, for columns: [org.hibernate.mapping.Column(students)]
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4037526#4037526

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4037526



More information about the jboss-user mailing list