Hey,
I have few entities inherited from a parent entity which is annotated with:
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
The subclasses entities has few ManyToOne relationships with other entities,
Since all the columns are kept in a SINGLE TABLE all the foreign keys columns must be nullable, (otherwise I get SQL exceptions when saving one of the entities due to missing values of the other foreign keys related to other entities),
So I tried to do in the child entities something like:
@ManyToOne(optional=false)
@JoinColumn(name="FOREIGN_KEY_ID", nullable=true)
I was sure that nullable=true means that the column will be created as nullable in the DB schema while 'optional=false' will make sure that the relationship was set by hibernate,
In reality, the column is created as NOT NULL (although I set nullable=true)
Is it the expected behavior? and if so, how can I make sure that when working with one of the child entities the relevant foreign entities are set?
Many thanks,
Asaf.
|