Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Migrating from OpenJPA - Non null constraints [PostgreSQL]

Also, I should note that entity B has an ID that is already populated.  The id is assigned, not generated.

> On Nov 13, 2014, at 4:15 PM, Hal Hildebrand <hal.hildebrand@xxxxxx> wrote:
> 
> So this is a weird one.  I have an entity A which has a FK to another entity B.  Entity A has a non null constraint on the FK to entity B.  The constraint is marked deferrable, initially deferred.  And in my test, I create entity B first, persist it. flush the entity manager.  Then I create entity A, set the value to entity B, and persist and flush.   I have a @ManyToOne annotation on the FK reference to entity B in entity A.
> 
> The problem is that I get an exception informing me that the non null constraint has been violated.  And, indeed, the insert being performed has the value null for entity B, despite having explicitly set this in entity A.
> 
> I’m kind of scratching my head here.  Surely, I must be doing something wrong because this seems like this would be an extremely common problem for any non trivial schema.



Back to the top