Hi,

Class A, has one attribute like the following :

    @ManyToOne(optional = true, cascade = CascadeType.ALL)
    @JoinColumn(name = "B_ID")
    private  B b = null;

Not surprisingly, this is producing, in the table A, a column like the 
following :
B_ID bigint(20) Yes NULL

Note that the column is nullable.

If I switch optional to false :
    @ManyToOne(optional = false, cascade = CascadeType.ALL)

The generated column is still nullable.

Any idea why ? I was waiting for not null join column in the database.

Despite that, it's all working fine 100%.
In case of a search on A, if optional = false, only A that has B are taken by 
the request.
If I switch back optional to true, all A (with ot without B) are taken into 
account.

So, it look like it works fine but why the column is nullable when optional = 
false ?

Using OpenJPA 2 with MySQL.

Thanks !

Reply via email to