aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Java Persistence API Entities Enthuware Wrong Answer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Java Persistence API Entities Enthuware Wrong Answer" Watch "Java Persistence API Entities Enthuware Wrong Answer" New topic
Author

Java Persistence API Entities Enthuware Wrong Answer

Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 844
Consider the following two entities...
@Entity public class Student{
...
@OneToMany
Collection<Presentation> presentations;
...
}

@Entity public class Presentation{
... // there is no reference to Student
}

Which of the following statements is true, when the two entities are mapped to database tables Student and Presentation?

1) A foreign key column will be created in Student table refering to the primary key of Presentation.

2) A foreign key column will be created in Presentation table refering to the primary key of Student.

3) A foreign key column will be created in both the tables refering to each other's primary keys.

4) A join table will be created.

explanation-Note that this is a Unidirectional One-To-Many relationship. Here, a join table is created. It has two foreign key columns. The first column refers to the primary key of the "one" side and the second column refers to the primary key of the "many" side. The second column also has a unique constraint on it. For example,: STUDENT_ID , PRESENTATION_ID

Join table is not used in bi-directional One-to-many relationship.

the correct asnwer given is 4.

But according to me the correct asnwer should be 1.
As i have already read in EJB 3 in Action, the join table's are only possible in case of manytomany relationship.


SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog- http://rkydesigns.blogspot.com
Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 844
ok i got it. A JoinTable annotation can be specified on the owning side of a many-to-many association, or a unidirectional one-to-many association.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Persistence API Entities Enthuware Wrong Answer