Page 1 of 1

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

Posted: Wed Mar 14, 2012 5:07 pm
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;
  ...
}

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

Posted: Wed Mar 14, 2012 7:44 pm
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.

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

Posted: Thu Mar 15, 2012 3:07 pm
by M_Z
Sorry, I was wrong.

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

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

Posted: Tue Aug 25, 2015 7:58 pm
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?

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

Posted: Tue Aug 25, 2015 9:42 pm
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.

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

Posted: Thu Sep 24, 2015 2:29 pm
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..."?

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

Posted: Fri Sep 25, 2015 8:43 am
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.

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

Posted: Fri Jul 01, 2016 3:51 am
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.

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

Posted: Fri Jul 01, 2016 9:47 am
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.

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

Posted: Thu May 04, 2017 8:09 am
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

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

Posted: Thu May 04, 2017 10:35 am
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.

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

Posted: Fri May 05, 2017 4:16 am
by javabean68
Upsi, sorry I didn't read the answer before!

Thank you!