wood burning stoves*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Doubt on @OneToOne bi-directional Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Doubt on @OneToOne bi-directional" Watch "Doubt on @OneToOne bi-directional" New topic
Author

Doubt on @OneToOne bi-directional

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

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, Certified Scrum Master
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
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Doubt on @OneToOne bi-directional
 
Similar Threads
The "optional" element on @OneToMany and @ManyToMany
OneToOne Lazy-load
JPA2.0 CascadeType.ALL doesn't cascade persist
Owner of the RelationShip
OneToOne composite key