Leo
Leo

Reputation: 2199

@ManyToOne foreign key NOT NULL field

In my Entity class I have a field annotated as follows:

@ManyToOne
@JoinColumn(name = "sport_id", nullable=false)
public Sport sport;

in SQL it generates

sport_id                  bigint,

but I expect it to be

sport_id                  bigint not null,

Is it a bug of Ebean?

Upvotes: 1

Views: 1236

Answers (1)

Steve Chaloner
Steve Chaloner

Reputation: 8202

Have you tried setting the optional flag of @ManyToOne?

@ManyToOne(optional=false) 
@JoinColumn(name = "sport_id", nullable=false)
public Sport sport;

Upvotes: 3

Related Questions