About Question enthuware.oce-jpad.v6.2.554 :

Moderator: admin

Post Reply
M_Z

About Question enthuware.oce-jpad.v6.2.554 :

Post by M_Z »

"...unidirectional one-to-many association"

Why option #3 is not correct ?

Even explanation says that it's correct. ;)

Also, there is a possiblity to create OneToMany unidirectional association without join table:

Code: Select all

@Entity
public class Employee {
  @Id
  @Column(name="EMP_ID")
  private long id;
  ...
  @OneToMany
  @JoinColumn(name="OWNER_ID", referencedColumnName="EMP_ID")
  private List<Phone> phones;
  ...
}

Code: Select all

@Entity
public class Phone {
  @Id
  private long id;
  ...
}

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.554 :

Post by admin »

I see that Option 3 is indeed marked as correct.
Yes, it is possible to create a one to many relationship without join table, but that is not relevant in this question.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

M_Z

Re: About Question enthuware.oce-jpad.v6.2.554 :

Post by M_Z »

Sorry, I was wrong.

I thought option 2 was correct (and therefore option 3 was wrong). :?

crolip
Posts: 6
Joined: Mon Jun 16, 2014 9:47 am
Contact:

Re: About Question enthuware.oce-jpad.v6.2.554 :

Post by crolip »

In question enthuware.oce-jpad.v6.2.429 is showed that is possibile to create a one-to-many association without the usage of a joinTable, so why option three is correct?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.554 :

Post by admin »

crolip wrote:In question enthuware.oce-jpad.v6.2.429 is showed that is possibile to create a one-to-many association without the usage of a joinTable, so why option three is correct?
Yes, but this question doesn't ask, "join table is must for which associations". It is only asking where jointable is used. It is used for unidirectional one-to-many association also.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Igor Makarov
Posts: 14
Joined: Tue Sep 08, 2015 3:27 am
Contact:

Re: About Question enthuware.oce-jpad.v6.2.554 :

Post by Igor Makarov »

Hi.
May be it would be better to rephrase a bit the question. Instead of "A JoinTable is used..." write "A JoinTable is placed on..."?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.554 :

Post by admin »

Igor Makarov wrote:Hi.
May be it would be better to rephrase a bit the question. Instead of "A JoinTable is used..." write "A JoinTable is placed on..."?
I am not sure what "is placed on" implies. "used" is quite clear in the sense that you need to use this annotation when you are creating a OneToMany or ManyToMany relationship. How exactly it is used is a different matter.

thank you for your feedback!
-Paul.
If you like our products and services, please help us by posting your review here.

tanzwud
Posts: 19
Joined: Mon Sep 01, 2014 9:45 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.554 :

Post by tanzwud »

Why option 4 is invalid?
"for all one-to-many as well as many-to-many associations."
11.1.23
"A join table is typically used in the mapping of
many-to-many and unidirectional one-to-many associations. It may also be used to map bidirectional
many-to-one/one-to-many associations, unidirectional many-to-one relationships, and one-to-one associations
(both bidirectional and unidirectional)."
Sounds like in any many-to-many and one-to-may unidirectional/bidirectional.
Thx, Ivan.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.554 :

Post by admin »

tanzwud wrote:Why option 4 is invalid?
"for all one-to-many as well as many-to-many associations."
...
Sounds like in any many-to-many and one-to-may unidirectional/bidirectional.
Thx, Ivan.
Yes, it "may" be but not necessarily so.
If you like our products and services, please help us by posting your review here.

javabean68
Posts: 31
Joined: Wed Mar 16, 2016 8:38 am
Contact:

Re: About Question enthuware.oce-jpad.v6.2.554 :

Post by javabean68 »

Hallo

I find the option 4 a bit confusing...
"for all one-to-many as well as many-to-many associations."

It should be 'for some'...shouldn't it?

Thank you
Fabio

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.554 :

Post by admin »

No, the problem statement contains, "may be". A join table may indeed be used for all one-to-many as well as many-to-many associations.
If you like our products and services, please help us by posting your review here.

javabean68
Posts: 31
Joined: Wed Mar 16, 2016 8:38 am
Contact:

Re: About Question enthuware.oce-jpad.v6.2.554 :

Post by javabean68 »

Upsi, sorry I didn't read the answer before!

Thank you!

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests