Jayesh A Lalwani wrote:First of all, JPA supports ManyToMany relationship. You shouldn't need to create an Entity class for StudentCourse table. You just need Student and COurse, and in the annotation you can use JPA to use the StudentCourse relationship table
Secondly, in your code you set calCourse to StudentCOurse, and then set a new Course to StudentCourse. Is that what you intended to do. The problem could be that the new COurse is not being saved properly. Can you post your COurse class? Is the ID tag placed on Course correctly?
Third, your naming conventions are a bit off. Usually, you would name your methods as StudentCourse.getStudent and StudentCourse.getCourse, not StudentCourse.getStudentbyStudentId and StudentCourse.getCourseByCourseId,
What I was trying to do was to get course and student object references to "feed" to a Hibernate method to then persist the new record in the M:M table.
The naming was done by Intellij 12, not me, and it doesn't create DAO objects as far as I can see.
Here's the Course Class generated by Intellij Entity reverse engineering.
I made these changes to the "main" class and it now works:
Do you know if there's any way to generate DAOs using Intellij? I can't find a plugin that works.