This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB and other Java EE Technologies and the fly likes Eclipselink unidirectional mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Eclipselink unidirectional mapping" Watch "Eclipselink unidirectional mapping" New topic
Author

Eclipselink unidirectional mapping

Aprajita Paul Choudhury
Greenhorn

Joined: Jan 04, 2014
Posts: 1
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.
 
wood burning stoves
 
subject: Eclipselink unidirectional mapping