0

In my project i have a Professor, a student and a group classes .In my project : the professor and the students have a lot in common the only difference between them is in the methods and the relation with the group class so i thought about inheritance and creating a person abstract class.
i was first confused between the three mapping choices but i finally choose the joined one but i don't know how to create the relations between the professor and the group (bidirectionnal ManyToMany) and the student and the group(ManyToOne and OneToMany).
i am used to map entities without the inheritance :now with this i am so confused .
edit (i am tunisian and we use french in our education)

   @Entity
    public class Etudiant {
private int cin;
private String nom;
private String prenom;
private String email;
private String motDePase;
private String imageProfil;

and this a part of the professor class

    @Entity
    public class Professeur {

private int cin;

private String nom;

private String prenom;

private String email;

private String motDePasse;

private String imageProfil;

i didn't create the person class yet i only created professor , student and group i first tried to work without the inheritance but then it was a duplicate code just a waste so i'm trying to figure out my way through the inheritance

MeknessiHamida
  • 185
  • 1
  • 8
  • 28
  • Show a code representation of what you mean. Then it would make more sense to both of us. – Prateek Nov 05 '13 at 20:17
  • Do you have different tables in the database for your entities or one table for both entities? – Alex Nov 05 '13 at 22:18
  • @Alex i didn't create the database yet i'm creating the entities and i wanna generate the tables from the entities and i m wondering how to create the relations with the group along with the joined inheritance strategy – MeknessiHamida Nov 06 '13 at 07:11

1 Answers1

0

Refer this for the difference between the annotations(ManyToOne and OneToMany) Difference

You can create a super class for both Professeur and Etudiant

  • Note : if you use interface, Every field in an interface is public, static and final.

Hope it helps.

Community
  • 1
  • 1
Ashish
  • 735
  • 1
  • 6
  • 15
  • i'll explain it more :view the commun points between professor and student i want to create an abstract super class for both of them but the problem is that where should i put the relation expression: do i put it in the super class or in professor(relation between professor and group is ManyToMany) and student(relation between student and group is one student for one group and many student for one group ) – MeknessiHamida Nov 06 '13 at 10:05
  • are you familiar with jpa and how tables are created or is this the first project on this technology ? – Ashish Nov 06 '13 at 10:13
  • no i already worked the jpa but without using the inheritance – MeknessiHamida Nov 06 '13 at 10:20
  • you should refer this http://docs.oracle.com/javaee/5/tutorial/doc/bnbqa.html#bnbqr – Ashish Nov 06 '13 at 10:29
  • i already read an approximate content in a book called ejb3 but i am still don't know what to do. I want to elimnate the duplication but the differnce in the relation with other entities and the autorisations of both of them make it hard to tell which solution to choose – MeknessiHamida Nov 06 '13 at 12:02