File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Eclipselink unidirectional mapping

 
Aprajita Paul Choudhury
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a table Student(ID integer PRIMARY KEY,Student name varchar(55),subj_ID INTEGER,CONSTRAINT Stud_FK1 FOREIGN KEY (subj_ID) REFERENCES Subject(ID)); and another table subject(ID integer PRIMARY KEY,Subject varchar(55))
ID in the Sudent and Subject table are generated by sequence defined in DB

In my Student entity class i have define
//uni-directional many-to-one association to Subject
@ManyToOne
@JoinColumn(name="subj_ID")
private Subject sub;
From the UI i am getting the Student name and subject Name.While am trying to persists the Student,its trying to add a new row in Subject class.But I dont want to add a new row for Subject table and only want that a respective ID for Subject table should be stored in Student table for the selected subject name.
I am new to eclipselink,could anyone suggest how i can join these two tables.
All examples that I see is having a Subject entity having a list of Student anf for each new Subject,list of students are saved in DB.But my requirement is,without adding a new Subject I want to add a Student details.
Thanks in advance.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic