File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Android Security Essentials Live Lessons this week in the Android 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Eclipselink unidirectional mapping
 
Similar Threads
Problems using GenerationType.IDENTITY for in-memory databases
Invalid composite primary key specification(jdeveloper 12c)
CRUD operations in Hibernate on 2 tables
many-to-one mapping issue EJB
JPA mapping with inheritance, elementcollection and many-to-many relationship