Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on @OneToOne bi-directional

 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens when we do not say optional = "false" in the OneToOne definition as below @OneToOne(mappedBy="billingInfo", optional="false");
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
S Bhanage
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic