Author
Doubt on @OneToOne bi-directional
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
What happens when we do not say optional = "false" in the OneToOne definition as below @OneToOne(mappedBy="billingInfo", optional="false");
SCJP 1.4, SCWCD 1.4 - Hints for you , SCBCD Hints - Demnachst , SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
Sergio Tridente
Ranch Hand
Joined: Mar 22, 2007
Posts: 329
The optional attribute is a hint used for schema generation. In the case we are talking about, the inverse (non-owning) side of a OneToOne association, my guess is that this attribute is ignored. [ September 01, 2008: Message edited by: Sergio Tridente ]
SCJP 1.4 (88%) - SCJP 5.0 Upgrade (93%) - SCWCD 1.4 (97%) - SCBCD 5.0 (98%)
S Bhanage
Greenhorn
Joined: Oct 28, 2009
Posts: 13
posted Oct 30, 2009 14:21:43
0
Hi,
The default value of optional is "true"
which implies that property can take null values while persistence.
If we explicitely specifies optional = "false"
This means we do not want to persist 'Null' value for this perticular property.
You can refer EJB 3 spec for more details.
subject: Doubt on @OneToOne bi-directional