Uploaded image for project: 'EJB 3.0'
  1. EJB 3.0
  2. EJBTHREE-1188

Deployment of @ManyToMany fails.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major Major
    • None
    • AS 4.2.1.GA
    • EJB3 Extensions
    • None

      Two entities relates as many to many (Course and Student).
      During deployment it throws:

      Caused by: org.hibernate.MappingException: Could not determine type for: java.util.Collection, for columns: org.hibernate.mapping.Column(students)]

      Both sides using Generics.
      Here is the latest code:

      @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
      public Collection<Course> getCourses() { return courses; }

      public void setCourses(Collection<Course> courses) { this.courses = courses; }
      }

      @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; }

      @ManyToMany(mappedBy = "courses")
      public Collection<Student> getStudents()

      { return students; }

      public void setStudents(Collection<Student> students)

      { this.students = students; }

      }

              Unassigned Unassigned
              tsirel84 Alexander Tsirel (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: