This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Java Persistence API Entities Enthuware Wrong Answer

 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Amandeep Singh
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Eat that pie! EAT IT! Now read this tiny ad. READ IT!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic